You are currently browsing the Pilot’s Logbook weblog archives for the day 17. January 2008.
- 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 17. January 2008
Updating Chapter 2
17. January 2008 by pilot.
Continuing with the review of the code examples for the latest revision of the MPLAB C30 compiler (3.02) it is time to look at Chapter 2.
There is a single example used in this chapter and the code needs no massaging beside remembering to disable the advanced warnings or otherwise ignore the obvious complaint about main() type (see previous post).
Here is the code: Loop.c
Notice that the definition of DELAY can be shortened to just 16 to speed up considerably (1000 x) the simulation when using only MPLAB SIM and the Logic Analyzer window.
We can also take the opportunity to complete the exercises proposed at the end of the chapter:
- The first exercise required us to replace the simple on/off sequence with a count.
Declaring an 8-bit integer called count (this might require some of you to peek into chapter 4 already) we get the mission accomplished quickly: Exercise 2-1. - The second exercise required us to replace the on/off sequence with a rotating pattern. To make things more interesting we will choose a 16-bit variable that we will call pattern. The exercise is actually quite valuable because it forces us to recognize the fact that in C language there is no concept of rotation, but there are only shift operators. So unless we make use of inline assembly, we are forced to take things in our hands and perform a three steps sequence: Exercise 2-2. Commenting and un-commenting different sections you will see examples of right and left rotations.
Adding all PORTA pins to the channels of the Logic Analizer will help get the full picture:
The C programming experts among you will not fail to recognize the opportunity to use special “shortcuts” using advanced operators such as +=, >>=, <<= and some conditional expressions trickery.
Posted in Tips and Tricks, PIC24 | No Comments »