Using timer 2 for clock out on P1.0 with keil

Status
Not open for further replies.

pasmosodico

Newbie level 4
Joined
Jun 23, 2011
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,337
i am using the example in the attachment file to configurate the timer2 as a clock out but i cant make it work

this is the example

#include <REGX52.h>
#define MSB_reload_value 0xFF /* msb reload value exemple */
#define LSB_reload_value 0xF2 /* lsb reload value exemple */
/**
* FUNCTION_PURPOSE: This file set up timer 2 in mode 1 (clock-out mode and
* negative transition detector).
* The 16-bits register consist of all 8 bits of TH2 and all 8 bits of TL2.
* TF2 does not generate interrupt.
* A negative transition on P1.1(T2EX) generate an interrupt.
* FUNCTION_INPUTS: void
* FUNCTION_OUTPUTS: P1.0(T2) as clock output : Fout = Fperiph / (2*(65536-
RCAP2)).
*/
void main(void)
{
T2MOD &= 0xFE; /* T2OE=1;DCEN=0; */
T2MOD |= 0x02;
EXF2=0; /* reset flag */
TCLK=0;RCLK=0; /* disable baud rate generator */
EXEN2=1; /* enable events on T2EX */
TH2=MSB_reload_value;/* Init msb_value */
TL2=LSB_reload_value;/* Init lsb_value */
RCAP2H=MSB_reload_value;/* reload msb_value */
RCAP2L=LSB_reload_value;/* reload lsb_value */
C_T2=0; /* timer mode */
CP_RL2=0; /* reload mode */
EA=1; /* interupt enable */
ET2=1; /* enable timer2 interrupt */
TR2=1; /* timer2 run */
while(1); /* endless */
}

using the "logic analizer in keil" i cant see anything in the pin p1_0
anyone can help, I need examples written in C because I do not understand much of assembler
 

Attachments

  • timer examples at89s52.pdf
    664.4 KB · Views: 64

i am using at89s52 with 24Mhz crystal
 

I use uVision v4.02 and all working OK!
P1.0 toggle in debug window.....
 

I use uVision v4.02 and all working OK!
P1.0 toggle in debug window.....

thanks for the reply

you saw him on the parallel port 1??

I want to see the logic analyzer, to make the correct measurement and compare with other output signals...
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…