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.

Urgent Help needed on 8051..

Status
Not open for further replies.

jayant.shrivastava

Newbie level 1
Joined
Sep 2, 2009
Messages
0
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,280
Activity points
1,312
tmod in timer 2

hey guys... below is my program for displaying the RPM count from the gear tooth sensor mounted on the flywheel of the engine. I am unable to set the register properly for overflow count and also I am not sure if I am getting proper results at the serial display....
I have written this program recently and have to be able to execute on the hardware in 2 weeks from now!... there are no errors as such in the program.
I need ur help urgently!!!!! can you just let me know if the program is right or do i have to make any changes....?????

I also have include PWM using PCA modules... is it possible for me to do that....
this PWM will be control the throttle position by the help of electro-magnetic solenoid valve...I am using timer 2...and im not sure which value to load into the count... should it be RCAP2L or somethings else???

this is the program I am using NXP(philips) make 8051 which has 3 timers and also a PCA module for PWM etc,... plzz help!!!! I will be displaying the RPM serially for every 1 second, but I think even that part by initializing the timer0 interrupt is not working properly..

#include<p89v51rx2.H>
#include <stdio.H>
#define INTERRUPT_Timer_2_Overflow 5
#define TRUE 1
#define FALSE 0

sbit Pulse_count=P1^1;

unsigned long int CountL, CountH, Count1=0; Flag_1sec, Count_Temp=0;

void Timer_2_Init(void);
void Timer_0_Init(void);
void RPM_Display_At_Controller_End(void);
void RPM_Display_At_User_End(void);
void Serial_Init(void);
void Serial_Display(void);

//
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//
void main(void)
{
Timer_2_Init();
Serial_Init(); // Set up Timer 2
EA = TRUE; // Globally enable interrupts
while(1)
{
if( Flag_1sec == TRUE)
{
Flag_1sec = FALSE;
Count1 = (CountH-CountL)+(Count_Temp);
RPM_Display_At_Controller_End();
RPM_Display_At_User_End();

}
}
}

//
//
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//
//
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//

void Timer_2_Init(void)
{
T2MOD = 0x0C9;
T2CON = 0x04; // Load Timer 2 control register
TH2 = 0xFC; // Load Timer 2 high byte
TL2 = 0x65; // Load Timer 2 low byte
RCAP2L = 0x65; // Load Timer 2 reload capt. reg. low byte
RCAP2H = 0xFC; // Load Timer 2 reload capt. reg. high byte
CountL = RCAP2L;
CountH = RCAP2H;
C_T2 = 1; // Set the counter
CP_RL2 = 1;
EXEN2 = 1,
ET2 = 1; // Timer 2 interrupt is enabled, and ISR will be called whenever the timer overflows
TR2 = 1; // Start Timer 2 running
}
//
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//
static void Feedback (void) interrupt INTERRUPT_Timer_2_Overflow
{
TF2=0;
CountL++;
CountH--;
Count_Temp++;
//EXF2=0;

}
//
//
//----------------------------------------------------------------------------------------
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top