You are currently browsing the archives for the Tips and Tricks category.
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
| « Jan | ||||||
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | |||
- 17. January 2012: Atypical Curiosity
- 4. January 2012: PIC32MX7 PIM, RB5 pin conflict (solved)
- 30. December 2011: MikroE Mini-32 Board
- 29. December 2011: Donate to Wikipedia
- 28. December 2011: PIC32 Interrupt Nesting (update)
- 20. December 2011: Graphics Library 3.02
- 2. December 2011: Home Brewed IDE for PIC32 assembly development
- 30. November 2011: Yoda Conditions, Egyptian brackets and more...
- 9. November 2011: AVI Player Project (for the uMMB)
- 21. March 2011: More Multimedia Boards
- January 2012
- December 2011
- November 2011
- March 2011
- February 2011
- January 2011
- March 2010
- January 2010
- December 2009
- November 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- January 2009
- December 2008
- November 2008
- October 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
Archive for the Tips and Tricks Category
PIC32MX7 PIM, RB5 pin conflict (solved)
4. January 2012 by pilot.
I need to thank Martin K. for bringing to my attention an issue that appears to be affecting quite a few of the readers of my PIC32 book when they attempt to use one of the new MX7 PIMs on the Explorer 16 board.
On the PIC32MX7 models the VBUSON and FVBUSONIO, are multiplexed with RB5 where the Explorer 16 connects instead the potentiometer. That could in fact cause an issue if it was not for the fact that the PIM sockets are NOT a 1 to 1 match to the PIC pins!.
See the document that comes with the PIC32MX7 PIM:
http://ww1.microchip.com/…n/DeviceDoc/51949A.pdf
and you will find that pin 20 on the Explorer16 (the pin actually connected to the potentiometer), is instead connected to pin 23 on the device, which corresponds to AN2.
So in the examples of Day 10, just read out AN2 instead (remember to adjust AD1PCFG and AD1CHS accordingly) and you will get a perfect representation of your potmeter’s position!
Posted in PIC32, Tips and Tricks | No Comments »
Good old printf() (continued)
30. September 2009 by pilot.
Continuing on the subject of using printf() as the most basic debugging tool, if you are using the MPLAB SIM software simulator to test portions of your code, you might be aware that the PIC simulator offers the possibility to simulate the UART1 module.
Simply open the Debugger menu, select Settings to open the Simulator Settings dialog box and in the UART1 I/O pane check the “Enable UART1 I/O” checkbox. This will give you two options:
· Record anything transmitted by UART1 into a file
· Send the transmitted data directly to the MPLAB Output window but in a separate pane, next to the Build pane, the Find in Files pane and the Debugger Output panes.
Posted in PIC32, Tips and Tricks | 3 Comments »
Where is my RAM?
24. July 2009 by pilot.
I know there are gobbles of RAM in a PIC32 (more than the entire FLASH bank in most other PIC16/18… ) but RAM is one of those things in life you can never have enough of!
Plus, I am an 8-bitter by education, as I have already acknowledged before, and having spent most of my professional life working on microcontrollers with very limited resources, I am very sensitive to waste and waste of RAM in particular.
If you check the memory gauges in MPLAB, even an empty PIC32 program with no function calls and practically no code at all in the main(), will give you a minimum memory usage of 1.5K bytes of RAM. To me that’s huge! I need to know where all this RAM is going and how I can control it should I need it all!
The mystery is easily solved, if you look at the .map file, it shows that 1k byte of that RAM is just the default amount “reserved” for the stack. As we have seen before (the stack so misunderstood…) the way MPLAB manages the stack memory allocation is a bit tricky. By the way, that memory is not literally allocated, nor the SP register is affected directly, but this number is used at compile time, only once, to check if , after allocating all the global variables and the heap (if there is one), there is still room for the requested amount of stack. So it shows in the memory gauges, but it is not representing by any means the “real” amount of RAM that will be used by your application stack, nor the maximum amount available. In fact the stack will take all the memory left and some… if it needs to.
But where is the other 1/2k byte of RAM gone?
Posted in PIC32, Tips and Tricks | 1 Comment »
Reporting Memory Usage
16. April 2009 by pilot.
I think I can say we all love the little Memory Usage gauges introduced in MPLAB a couple of years ago.. or was it more?
When working in assembly with an 8-bit microcontroller and a couple of Kbytes of FLASH memory they definitely do their job, but when using the PIC24 or PIC32 type of devices, the memory space grows into the hundreds of Kbytes and things get … well, more complicated!
You start including a stack here (USB?) and a library there (Advanced Graphics), the compiler throws in a couple library modules of its own (math libs, stdio…) and both FLASH and RAM spaces become a little more crowded. It does not take long before we start wondering who is using up more memory, and why… the little memory gauges just don’t cut it anymore.
The experts will tell you right away that the sensible thing to do is to turn on the “map” option of the linker, (Project Build Options, Linker Tab, Select Diagnostics pane, then Check Create Map file) and inspect the resulting .map file in the editor window. But the text file generated is a pretty complex (and long) document and browsing through it in search of clues about what happened to our program and data memory can be quite hard work.
Fortunately with the latest version 1.05 of MPLAB C32 compiler there is a new option for the linker to produce a detailed summary of your project memory usage: –report-mem. Read the rest of this entry »
Posted in PIC32, Tips and Tricks, MPLAB | No Comments »
Good Old printf()
13. April 2009 by pilot.
Good old printf() is probably the oldest debugging tool ever used, I mean beside a light bulb (nowadays replaced by an LED) … yet it represents a pretty sophisticated one when working in a deeply embedded control project. If you take the standard definition of the printf() function (as in the ANSI C standard) it assumes that you will be able to convert and print integers and floating point numbers of any size, and use a myriad of formatting options.
Assuming you have a serial port (UART) to spare for the interface with a terminal (Hyper- if you use a PC) it is the code space requirements (even excluding the floating point support) for a full implementation that makes it a difficult choice. It could be pretty large (several K of code), comparable if not more than the entire program memory available on some 8-bit microcontrollers.
So in the past I have used a bit of everything to avoid relying on printf() for my debugging/diagnostic output. Mostly macros including itoa() followed by puts() and a mix of other hand made optimizations for simple hex output.
In the 16-bit and 32-bit world, there is a little bit more room to breathe, and with a smart compiler’s help, things get manageable. Read the rest of this entry »
Posted in PIC32, Tips and Tricks | 2 Comments »
Literally Bits
7. April 2009 by pilot.
The new version of the MPLAB C32 (v1.05) compiler is out and is filled with new features and a new (as in additional) DSP library designed for compatibility with the dsPIC standard DSP lib. But for me the most exciting piece of news is that “binary” is back.
One of the simplest extensions to the ANSI C standard offered on all previous Microchip compilers was the ability to define and use binary literals using the “0b” prefix. Example:
int x = 0b000100011; // instead of 0×23
Now you can use the binary notation with the MPLAB C32 compiler too.
I have to admit, when you are working with 32-bit long literals, binary could get a bit … tyring, but if you are like me, with a ton of PIC18 and PIC24 code to use and re-use, it sure comes handy…
Posted in PIC32, Tips and Tricks | No Comments »
Using the 32-bit Core Timer
2. April 2009 by pilot.
One of the features of the PIC32 that I have so far somewhat left out in my “explorations” is the 32-bit Core Timer. This is in fact a piece of the MIPS M4K core itself and is common to all MIPS processors. This makes it a very popular item in typical MIPS literature, but from the PIC32 perspective (and in particular my 8-bitter perspective) this is an odd element that I decided not to focus on. And I don’t mean “odd” in a bad way, it just does not find an equivalent in the traditional Microchip architectures, where all timers are numbered and there is a long legacy and compatibility trail for each one of them. The Core Timer is in fact pretty useful and here I would like to illustrate the most obvious use we have for it… Read the rest of this entry »
Posted in PIC32, Tips and Tricks | No Comments »
Testing the PIC32 I/O Speed
18. March 2009 by pilot.
In the last several months I have seen a couple of postings on the PIC32 forum about users testing the speed of the PIC32 I/O. It is quite normal and healthy for a community of Embedded Control designers to worry about the actual I/O performance of a microcontroller, and even more so when the microcontroller in question claims to be able to operate all its peripherals (I/O pins included) at the same (top) speed of the core: 80MHz!
With such capability and thanks to the special Atomic I/O operations (PORTINV), the theory says that a PIC32 could produce a 40MHz output square wave!
This performance is quite unique among competing microcontrollers (they typically achieve 1/2 the processor top speed), but we have to admit it can be tricky to prove. Here is what I recommend you do to get as close to the theoretical limit as possible… Read the rest of this entry »
Posted in PIC32, Tips and Tricks | 2 Comments »
Merry Christmas and Happy New Year
27. December 2008 by pilot.
I guess we all wait for the Christmas holidays to recover from a long year of hard work, enjoy some more time with family and friends and prepare for the new year at the doors. As I am writing this, it’s real cold and snowy outside, just like in the typical Christmas stories, and I find that this is just the perfect time (after dinner and when the kids are in bed) to … write some fun embedded applications!
I had meant for a while to post some additional projects for those of you who have read the books and tried out (prototyped) the projects using the published schematics or assembling the AV16/32 kits, but I never got to it.
So, finally ..here they are! I have just added a new page to the PIC32 explorers’ web site dedicated to the first six new projects.
More will be coming shortly… hope you’ll have fun!
Posted in PIC32, Tips and Tricks, AV16/32 | No Comments »
Bending the laws of physics
19. November 2008 by pilot.
As a reader pointed out today, when preparing one of the pictures in Chapter 3, I did use a little trick, I had almost forgotten…
I did reduce the DELAY constants by a factor of 100 to … speed things up … so to speak. Otherwise the Logic Analyzer window would not be able to contain all the samples required to produce the complete “Hello” message.
I do these things quite a bit when I use the Simulator … Read the rest of this entry »
Posted in Tips and Tricks | No Comments »
