Hi to everyone,
I wanna switch from mplab to piklab with sdcc. So I need some help
about my coding:
Action that I want into the code:
Read a value from ADC.
When value reach level a: led green on
When value reach level b: led green off - led yellow on
When value reach level c: led yellow off - led red on
Here my code for a pic12f675:
typedef unsigned int config;
config at 0x2007 __CONFIG = _INTRC_OSC_NOCLKOUT & // Internal oscillator
_WDT_OFF & // No Watchdog
_PWRTE_ON;
short a,b,c,valore,v;
int read_adc(void)
{
int Value;
ADON =1; //ADC on
GO_DONE=1;
// starting conversion
while(GO_DONE==1)
{
//waiting
};
Value = ADRESH;
ADON =0; //turn off ADC
return (Value);
} //End ReadAdc
main()
{
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;
if (valore>b) v=v&0b0100;
if (valore>a) v=v&0b1000;
TRISIO=v;
}
}
This is my first coding with sdcc... please help a novice :-) with
your patience.
Thanks in advance
v.
------------------------------------------------------------------------------
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