View previous topic :: View next topic |
Author |
Message |
robertopi Guest
|
problem with port_D helpme please |
Posted: Mon May 17, 2004 6:14 pm |
|
|
thank u friend for your help but a have a little I can't to set portD (output)
my pic is 16f877 and my code is:
#include "C:\proyecto2\programa pics\cad1.h"
#byte puertab = 06
#byte puertac = 07
#byte puertad = 08
void main()
{
setup_adc_ports(ALL_ANALOG);
setup_adc(ADC_CLOCK_DIV_8);
set_tris_b(0x00);
set_tris_c(0x00);
set_tris_d(0x00);
while(true)
{
//int value0;
set_adc_channel(0);
delay_us(10); //Add this delay here
puertab = Read_ADC();
delay_us(10);
delay_us(10);
set_adc_channel(1);
delay_us(10); //Add this delay here
puertac = Read_ADC();
delay_us(10);
set_adc_channel(2);
delay_us(10); //Add this delay here
puertad = Read_ADC();
delay_us(10);
}
}
and cad1.h :
#include <16F877.h>
#device adc=10
#use delay(clock=4000000)
#fuses NOWDT,XT, NOPROTECT
I don't know what is the problem CCS or my code because all my code is OK but when I used "#byte puertad = 08" CCS writed:
"A numeric expression must appear here" on the number 8 .
please helpme . bye friend |
|
 |
Guest
|
Re: problem with port_D helpme please |
Posted: Mon May 17, 2004 10:31 pm |
|
|
robertopi wrote: |
#byte puertad = 08
|
The compiler doesn't like the leading zero. It's customary to write it in hex as
#byte puertad = 0x08 |
|
 |
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Tue May 18, 2004 9:48 am |
|
|
Check this, are you working with low voltage ? If not NOLVP is mandatory.
Quote: |
#fuses NOWDT,XT, NOPROTECT
|
You set AD conversion result will be 10 bit wide.
Commenting out //#device adc=10 the result of the AD conversion will be 8 bit wide. Default condition.
Then you can get the AD result in 8 bit format
Quote: |
puertad = Read_ADC();
|
HTH
Humberto |
|
 |
|