Dear Vittore,
you want to setup the ADC before you start, like:
ADCON0 = 0x00;
ANSEL = 0x01;
in main().
> main()
> {
ADCON0 = 0x00; /* new */
ANSEL = 0x01; /* new */
> TRISIO=0b0001; //pin 0 input - pin 1-4 output
> a=10;
> b=20;
> c=200;
> for(;;)
> {
> valore=read_adc();
> v=0;
> if (valore>c) v = v | 0b0010; /* or even: v = 0b0010; */
> else if (valore>b) v = v | 0b0100; /* or: v = 0b0100; */
> else if (valore>a) v = v | 0b1000; /* or: v = 0b1000; */
> GPIO=v;
> }
> }
>
You do *not* want to bitwise AND something with 0,
try bitwise OR instead (though that will light up all
LEDs for large inputs instead of only the red one).
You also do *not* want to reconfigure TRISIO with the output value,
you want to apply the latter to GPIO to influence the output pins.
I didn't check the config values nor run any tests,
but these hints might already get you started.
BTW: A description of your problem (compiler complaining, no output,
things you already tried (can you turn on/off the LEDs without ADC?))
might motivate others to give you feedback...
Kind regards,
Raphael
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user