Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem with computing voltage using 8051 analog comparators

Status
Not open for further replies.

mondoemme

Newbie level 4
Joined
Jun 10, 2005
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,324
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:


...
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
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top