pasmosodico
Newbie level 4
![Newbie level 4](/styles/images/ranks/blevel1.gif)
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
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