kodi.sudar
Member level 5
- Joined
- Dec 21, 2009
- Messages
- 92
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Location
- india
- Activity points
- 1,849
I have tried with a timer toggling the output at 1KHz with the PLL on (60MHz, 1/4 PCLK), when I turned if off I git 1/5 of the frequency (200Hz)
Use this code and measure the frequency in P0.22
Code:#include <LPC213x.h> int main(void) { /* P0.22: MAT0.0 (Match output for Timer 0 channel 0) */ PINSEL0 = 0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ IO0DIR = 0x80000000; /* binary: 10000000_00000000_00000000_00000000 */ PINSEL1 = 0x00003000; /* binary: 00000000_00000000_00110000_00000000 */ PINSEL2 = 0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ IO1DIR = 0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ /****************************************************************************** Timer0 (32bit) ******************************************************************************* Counter Enabled, Counter Reset=0 Timer mode: count on rising edge of PCLK Counter clk: 4 KHz, Counts every: 250 us (calculated with peripheral clock: 15MHz) MCR0.0 : reset, on compare match MAT0.0 : On compare match Toggle bit/output */ PCONP = (PCONP & 0x001817BE) | (1UL<<1); /* Enable peripheral clock for Timer0 (default is enabled) */ T0CTCR = 0x00; /* binary: 00000000 */ T0TC = 0x00000000; /* decimal 0 */ T0PR = 0x00000EA5; /* decimal 3749 */ T0MCR = 0x0002; /* binary: 00000000_00000010 */ T0MR0 = 0x00000001; /* decimal 1 */ T0MR1 = 0x00000000; /* decimal 0 */ T0MR2 = 0x00000000; /* decimal 0 */ T0MR3 = 0x00000000; /* decimal 0 */ T0CCR = 0x0000; /* binary: 00000000_00000000 */ T0EMR = 0x0031; /* binary: 00000000_00110001 */ T0TCR = 0x01; /* binary: 00000001 */ while(1) { } }
Yes the frequency is around 200 hz .
- - - Updated - - -
I have tried with a timer toggling the output at 1KHz with the PLL on (60MHz, 1/4 PCLK), when I turned if off I git 1/5 of the frequency (200Hz)
Use this code and measure the frequency in P0.22
Code:#include <LPC213x.h> int main(void) { /* P0.22: MAT0.0 (Match output for Timer 0 channel 0) */ PINSEL0 = 0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ IO0DIR = 0x80000000; /* binary: 10000000_00000000_00000000_00000000 */ PINSEL1 = 0x00003000; /* binary: 00000000_00000000_00110000_00000000 */ PINSEL2 = 0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ IO1DIR = 0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ /****************************************************************************** Timer0 (32bit) ******************************************************************************* Counter Enabled, Counter Reset=0 Timer mode: count on rising edge of PCLK Counter clk: 4 KHz, Counts every: 250 us (calculated with peripheral clock: 15MHz) MCR0.0 : reset, on compare match MAT0.0 : On compare match Toggle bit/output */ PCONP = (PCONP & 0x001817BE) | (1UL<<1); /* Enable peripheral clock for Timer0 (default is enabled) */ T0CTCR = 0x00; /* binary: 00000000 */ T0TC = 0x00000000; /* decimal 0 */ T0PR = 0x00000EA5; /* decimal 3749 */ T0MCR = 0x0002; /* binary: 00000000_00000010 */ T0MR0 = 0x00000001; /* decimal 1 */ T0MR1 = 0x00000000; /* decimal 0 */ T0MR2 = 0x00000000; /* decimal 0 */ T0MR3 = 0x00000000; /* decimal 0 */ T0CCR = 0x0000; /* binary: 00000000_00000000 */ T0EMR = 0x0031; /* binary: 00000000_00110001 */ T0TCR = 0x01; /* binary: 00000001 */ while(1) { } }
But for me i am getting 200hz even after turning on PLL in startup.s am i making any mistakes ?