Great work fine. Here the final (rilevant) code:
/* Define processor and include header file. */
#define __12f675
#include "pic/pic12f675.h"
int at 0x2007 __config = _CP_OFF & _CPD_OFF & _BODEN_OFF &
_MCLRE_OFF & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT;
int getValue(void)
{
int Value;
ADON =1;
GO_DONE=1;
while(GO_DONE==1)
{
};
Value = ADRESH;
ADON =0;
return (Value);
} //End ReadAdc
main()
{
TRISIO=1;
GPIO=0;
a=10;
b=25;
c=50;
for(;;)
{
valore=getValue();
v=0;
if (valore>c) v = __rosso;
else if (valore>b) v = __giallo;
else if (valore>a) v = __verde;
GPIO=v;
}
}
v.
2009/6/9 Raphael Neider <[email protected]>:
> 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
>
--
dott. Vittore Zen (IWA member 0267825)
Email: [email protected]
Profile: http://www.linkedin.com/in/vittorezen
Web: http://www.zen.pn.it
------------------------------------------------------------------------------
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