> Can someone please direct me to some examples of C code for the PIC? > Or better yet, a "How to program microcontrollers in C" book would be > great. > http://www.phanderson.com/PIC/PICC/ > I've been dinking around with MPASM for a while now and am pretty new to > C programming. I'm having trouble figuring out how to map the > abstraction of a high level language to the specific microprocessor at > hand. > > For instance ... in HT-Softs PICCLite, printf() calls sprintf( stdout, > ...) > I can't for the life of me figure out where stdout is defined. If I was > interfaced to a VT100 I wouldn't hardly care, but there is no way that > the compiler could know that the stdout I had in mind was a 4 by 7-seg > LED display. So, I began to write my own dispout(). How do I pass in a > float or int or char and make dispout do the right thing on an 8 bit > micro??? > Sorry, don't know anything about HTech's compiler. The CCS PCM allows you to replace that "output stream" argument with a function that accepts bytes and returns void. This allows you to do anything you want with printf's output, thusly: void OutChar(BYTE byCharacter) { static int s_nCurrentLED=0; s_nCurrentLED %= TOTAL_LEDS_IN_SYSTEM; LEDMultiplexerEnable(s_nCurrentLED++); PutLEDPort(byCharacter); } void main(void) { int nIndex; for (nIndex=0;nIndex < 0x45;++nIndex) { printf(OutChar,"%d",s_nCurrentLED); } } > The only books I've found regarding microcontroller programming in C are > Motorola or ByteCraft specific. A more general guide is what I'm > looking for. I think you're going to be disappointed here. The very strength of a microcontroller is in its specifics. I have never seen a compiler targeted for a microcontroller without specific hooks to take advantage of particulars in the microcontroller. Well, 'cept for GCC, and the like. -d -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu