mondoemme
Newbie level 4
8051 Analog Comparators
Hi,
I'm newbie in programming anu using MCU 8051, can anyone help me to fix the above problem,
I have to use MCU analog comparator and an RC network to compute a measure
of voltage:
...
...
The code doesn't run but anyway when the ISR is called, how can I fetch the Voltage value?
Thanks in advance
Hi,
I'm newbie in programming anu using MCU 8051, can anyone help me to fix the above problem,
I have to use MCU analog comparator and an RC network to compute a measure
of voltage:
...
Code:
void InitComp(void)
{
UINT uiLoop;
//Disab Dig Input pin 1 (CIN2B) e 5 (CMPREF) port 0
PT0AD = 0x22; // 00100010
//Disab dig Out pin 0 , 5 of port 0
P0M1 = 0xFE; //bit 0 --> Quasi Bid, bit 1-7 input only ;
P0M2 = 0x00; //
CMP2 = 0x32;
// wait 10 msec (RC-Oscillator 7.328MHz)
for (uiLoop = 0; uiLoop < 10000; uiLoop++);
EC = 1; //Enable Comp1 interrupt IEN1 bit 2
EA = 1;//Enable all interrupts IEN0 bit 7
}
void main()
{
whille (1);
}
// This Comp1 ISR is called whenever the comparator
// output changes state
void v_CompInt(void) interrupt 8
{
CMP2 = CMP2 & 0xFE; // clear CMF2-Flag
if (sbLED == 0)
sbLED = 1;
else
sbLED = 0;
The code doesn't run but anyway when the ISR is called, how can I fetch the Voltage value?
Thanks in advance