On Thu, Jan 29, 2009 at 3:41 PM, DVD wrote: > I wrote that I'm writing the program in ASM, but actually I haven't even > chosen the PIC. > > Some time ago I started in ASM as everyone and later tested some C > compilers like HITECH, CCS and mikroC, but don't know which one is the > 'right' one. Everyone had something good and something bad, so now I have > some programs in all of them :), but prefer ASM. > > As you say I should use C to make my life easier and maybe it's the > HITECH's turn again. > > David HI-TECH C and Microchip C are the closest you can get to "real" C. They're also very higly optimizing compilers, especially HI-TECH. CCS is just garbage. Well, it may be ok for certain small things but it produces very bloated output. Also, if you use HI-TECH or Microchip C, it's VERY easy to translate your asm code into C. For example, if you have in ASM: movlw 0x08 movwf PORTC In C, you would do: PORTC = 0x08; Another example: var res 1 movlw 0x2F andlw 0xF0 movwf var In C, you would do: typedef unsigned char byte; //the term byte now represents an unsigned char type (a single byte) byte var = 0x2F & 0xF0; As you can see, the thought process is very logical in C and very natural. It may not seem completely advantagous now, but once your programs get more complicated and you require the use of ints, floats, longs and so on, you'll need C unless you want to waste time implimenting the fundamentals in ASM when your time could be better spent writing the actual application logic. Also, another advantage to using HI-TECH or Microchip C compilers is that their headers are almost, if not completely identical to the MPASM headers. That means you can use the address constants just as you were using ASM. Example, if you want to access PORTC, just use PORTC. If you want RCREG, just use RCREG. If you want AD1ON (a bit in ADCON1 I believe), just use it like that with its actual name. Also, they have some nice delay stuff there too where you just specify your clock frequency in your code and call delay_us or something like that. Even still, to use the high level functions like printf, all you need to do is impliment putch(unsigned char); in your code and you can use pretty much the full functionality of printf in your microcontroller code. Use C. -- solarwind -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist