View previous topic :: View next topic |
Author |
Message |
JimB
Joined: 25 Aug 2005 Posts: 65 Location: Huntington Beach, CA
|
Questions about lcd_putc() and the A/D setup? |
Posted: Thu Oct 06, 2005 2:32 am |
|
|
1) When setting up the A/D isn't the first line redundant with the third?
setup_adc_ports(ALL_ANALOG);
setup_adc( ADC_CLOCK_INTERNAL );
set_adc_channel( 0 );
If one is only using pin 0 isn't the following all that is needed?
set_adc_channel( 0 );
setup_adc( ADC_CLOCK_INTERNAL );
2) Why and when are the two different print statements for an LCD required?
printf(lcd_putc,"............)
lcd_putc("................) |
|
|
Foppie
Joined: 16 Sep 2005 Posts: 138 Location: The Netherlands
|
|
Posted: Thu Oct 06, 2005 2:42 am |
|
|
1) no, it is needed to declare what port is analog and what port is the Vref
look into the .h file of your used PIC to see which declaration you should use
2) with printf() you can use a string and I thought lcd_putc() only accepts characters. But I'm not quit sure about the last part... |
|
|
Ttelmah Guest
|
|
Posted: Thu Oct 06, 2005 5:00 am |
|
|
lcd_putc, is just the routine to send a character. in CCS C, there is a 'shortcut', for contant strings only, where if they are put as the 'target' for a function that wants individual bytes, the routine will be repeately called for each character in turn.
printf, is the full 'formatted output' routine, which allows variabes to be converted for output. It happens to have as one 'subset' possibility, the same ability to send a constant string. The compiler generates the same code for each. Normally you would use printf, where you want to do more than just print a constant string.
Best Wishes |
|
|
|