c_tips_and_tricks_for_pic_programming
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
c_tips_and_tricks_for_pic_programming [2007/12/18 10:07] – added bitfields, cleaned up headline-levels audiocommander | c_tips_and_tricks_for_pic_programming [2011/09/15 07:14] (current) – ichaljhe | ||
---|---|---|---|
Line 11: | Line 11: | ||
</ | </ | ||
* There' | * There' | ||
+ | * The [[http:// | ||
* If this is not enough, you could search for ASM optimized custom functions. You'll find some in code examples of TK, the [[ACSensorizer]] and a lot of PIC-Specialized Webpages – or of course the forum. | * If this is not enough, you could search for ASM optimized custom functions. You'll find some in code examples of TK, the [[ACSensorizer]] and a lot of PIC-Specialized Webpages – or of course the forum. | ||
- | * If that still is not enough or you have no time and a lot of processing power / space available on your PIC, you can include the **libsdcc library**: | + | \\ |
+ | \\ | ||
- | >> | + | ==== MIOS LIBSDCC Library ==== |
+ | |||
+ | If that still is not enough or you have no time and a lot of processing power / space available on your PIC, you can include the **libsdcc library**. Using the new MIOS GPUtils structure, this will be included automatically as required. | ||
+ | |||
+ | When using the library, sometimes | ||
\\ | \\ | ||
- | ====== Bitfields, Unions & Structs | + | |
+ | ==== Bitfields, Unions & Structs ==== | ||
* Avoid using huge int- or char-arrays when you just need to store some ON/OFF values. Use a bitfield instead | * Avoid using huge int- or char-arrays when you just need to store some ON/OFF values. Use a bitfield instead | ||
Line 45: | Line 52: | ||
// get number | // get number | ||
mynum = something.ALL; | mynum = something.ALL; | ||
+ | |||
</ | </ | ||
- | >> | + | |
+ | >> | ||
- | \\ | ||
====== C Functions ====== | ====== C Functions ====== | ||
Line 71: | Line 79: | ||
* Adding the keyword ' | * Adding the keyword ' | ||
- | * Always use ' | + | * Always use ' |
Line 96: | Line 104: | ||
unsigned char value = MIDIValues[1]; | unsigned char value = MIDIValues[1]; | ||
MIOS_MIDI_TxBufferPut(value); | MIOS_MIDI_TxBufferPut(value); | ||
+ | </ | ||
+ | In most cases, adding parenthesis around your index variable has the same effect (see tip further down) | ||
+ | <code c> | ||
+ | MIOS_MIDI_TxBufferPut((MIDIValues[1])); | ||
</ | </ | ||
Line 101: | Line 113: | ||
==== Large Arrays ==== | ==== Large Arrays ==== | ||
- | Arrays with more than 256 elements will produce compile (in fact linker) errors: | + | Arrays with more than 256 bytes of elements will produce compile (in fact linker) errors: |
<code c> | <code c> | ||
unsigned char myArray[256]; | unsigned char myArray[256]; | ||
Line 108: | Line 120: | ||
unsigned char myArray[64][4]; | unsigned char myArray[64][4]; | ||
unsigned char myArray[64][5]; | unsigned char myArray[64][5]; | ||
+ | |||
+ | unsigned int myArray[128]; | ||
+ | unsigned int myArray[129]; | ||
</ | </ | ||
Line 194: | Line 209: | ||
// | // | ||
// | // | ||
- | Note that stacks greater than 256 bytes will not work with SDCC at present. | + | Note that stacks greater than 256 bytes will not work with SDCC at present. |
c_tips_and_tricks_for_pic_programming.1197972476.txt.gz · Last modified: 2008/02/11 13:40 (external edit)