m8052
Newbie level 3
- Joined
- Jun 8, 2013
- Messages
- 4
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 34
Hi there,
I am having hard time understanding a couple of codes below. These are written for 8052 AT89S52 microcontroller.
The only thing I know about these is that they are specific bit registers...
If you could please explain it a bit more what their purpose is, that would be great! Thanks.
Another question is if I am using external interrupts INT1 AND INT0, do I need to use different timer for these?
For examle,
after this, should I initialise the Timer 0 like this? is this the right thing to do?
I am having hard time understanding a couple of codes below. These are written for 8052 AT89S52 microcontroller.
The only thing I know about these is that they are specific bit registers...
Code:
bit update_flag=0x10;
bit zv_flag=0x12; /* ZV_flag here*/
bit zc_flag=0x12; /* ZC_flag here*/
bit lead_flag=0x12; /* LEAD_flag here*/
bit lag_flag=0x14; /* LAG_flag here*/
bit time_possibilities=0x11;
If you could please explain it a bit more what their purpose is, that would be great! Thanks.
Another question is if I am using external interrupts INT1 AND INT0, do I need to use different timer for these?
For examle,
Code:
void int0_ZVS(void) interrupt 0
{
if (lag_flag==1)
/* If lag_flag is enabled, reset the timer and set the timer */
{
TMOD|=0x10; /* Initialisation of Timer1 16 bit Timer */
TH1=0x00; /* Reset high value of the timer1 */
TL1;0x00; /* Reset low value of the timer1 */
TR1=1; /* Set the timer1 */
zv_flag=1; /* Set zv_flag */
}
after this, should I initialise the Timer 0 like this? is this the right thing to do?
Code:
void timer() /* Timer function */
{
/* Using built-in timers start.
Timers are needed to track the high and low point of the signals */
TMOD=0x01; /* Setting the mode1 of Timer0 */
TH0=0x00; /* Set the timer for high */
TL0=0x00; /* Set the timer for low */
/* Using built-in timers end */
}