void PWM_3_Set_050(void)
{
T2CON &= 0xFD; // Clear *only* C /T2 bit
T2MOD |= 0x02; // Set T2OE bit (omit in basic 8052 clone)
// Set at lowest frequency (~45Hz with 12MHz xtal)
// - adjust as required (see PRM HARDWARE)
TL2 = 0x00; // Timer 2 low byte
TH2 = 0x00; // Timer 2 high byte
RCAP2L = 0x00; // Timer 2 reload capture register, low byte
RCAP2H = 0x00; // Timer 2 reload capture register, high byte
ET2 = 0; // No interrupt.
TR2 = 1; // Start timer 2
}
You can get 42.1867Hz ~ 2.7648MHz which depends on the osc freq. and value of RCAP2 (H,L).Help said:Osc Freq. = 11.059Mhz
Clock-Out Freq. (Theoretical) = (Osc Freq.) / (4*65536) = 42.1867Hz
Clock-Out Freq. (Practical) = 1 / 23.7mSec = 42.1941Hz
am i rite?
So, the clock-out freq. depends on the osc freq. If i'm using 11.059MHz then i only can get 42.19Hz clock generator, rite?
..... to output a 50% duty cycle clock...".
What does it mean? What's the 2nd function is it and how it works?
T2CON &= 0xFD; // Clear *only* C /T2 bit
T2MOD |= 0x02; // Set T2OE bit (omit in basic 8052 clone)
No, they are different, refer to Figure 1 on datasheet for Counter 2 with external Clock Source (injected to T2 pin), and figure 5 is Timer2 as clock generator configuration.Is it the Timer/Counter 2 and the clock-out setting is the same? How it work actually?
What do you want to do?How to do the setting on the code and how can i play on it?
budhy said:Setup Counter 2 with external Clock Source :
Set Timer2 operate on 16-Bit Auto-Reload or 16-Bit Capture mode (Tabel 3)
Clear T2OE = 0
Set C/T2 = 1 (Figure 1)
Set TR2 = 1 (start timer)
void CounterII(void)
{
T2CON &= 0xFF; // Set C bit
T2MOD |= 0x00; // Clear T2OE bit
TR2 = 0; // The timer should be turned off(clear TR2) before accessing the T2 or RCAP2 registers.
TL2 = 0xf0; // Timer 2 low byte
TH2 = 0xff; // Timer 2 high byte
RCAP2L = 0xf0; // Timer 2 reload capture register, low byte
RCAP2H = 0xff; // Timer 2 reload capture register, high byte
ET2 = 1; // T2 interrupt.
EA = 1; // Globally enable interrupts
EXEN2 = 1;
RCLK = 1;
TR2 = 1; // Start timer 2
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?