How to set up a 200uSec interrupt using lpc1227

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How to set up a 200uSec interrupt using lpc1227

1,206 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Mario on Wed Oct 26 17:40:11 MST 2011
on PG 12 of the LPC1227 UM10441, Manual (user manual) it says this:

"The main clock, and the clock outputs from the IRC, the system oscillator, and the
watchdog oscillator can be observed directly on the CLKOUT pin."

how do I setup PIO_12 to have the CLKOUT FUNC?
0 项奖励
回复
4 回复数

1,185 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by OA santana on Tue Feb 28 03:13:50 MST 2012
That should be enough.

/*******    syscon_Configuration    *******/


/* select which clock is driving the monitor IO pin*/
/* set div ratio to 256*/
SYS_ConfigCLKOUTCLK(SYS_MAINCLKOUT, 0xff);


/*******    gpio_Configuration    *******/
void gpio_clkout(void) {
IOCON_PIO_CFG_Type PIO_ConfigStructure;
  IOCON_StructInit(&PIO_ConfigStructure);
  /* configure output clk  for debug purpose  PIO0_12*/
  PIO_ConfigStructure.type = IOCON_CLOCKOUT_PIN;
  IOCON_SetFunc_mod(&PIO_ConfigStructure);  
}
0 项奖励
回复

1,185 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by NXP_Europe on Sat Oct 29 11:54:21 MST 2011
Hello Mario,

See User Manual UM10441 chapter 'Systick Timer':

[FONT=Courier New][SIZE=2]example with systick every 10 mSec:[/SIZE][/FONT]

[SIZE=2][FONT=Courier New]RELOAD = (system tick clock frequency * [/FONT][FONT=Courier New]10 ms) - 1 [/FONT][/SIZE]

[LEFT][SIZE=2][FONT=Courier New]= (30 MHz * 10 ms) - 1[/FONT] [/SIZE]
[FONT=Courier New][SIZE=2]= (30 000 000 * 0.01) - 1[/SIZE][/FONT]
[SIZE=2][FONT=Courier New]= 300 000 - [/FONT][FONT=Courier New]1[/FONT] [/SIZE]
[FONT=Courier New][SIZE=2]= 299 999 [/SIZE][/FONT]
[FONT=Courier New][SIZE=2]= 0x000493DF[/SIZE][/FONT][/LEFT]


[LEFT]You can change the '10 ms' value in '0.2 ms' ... redo the calculations and
the systick-timer will run at 200 uS[/LEFT]

[LEFT]Other possibility is to use a normal Timer.[/LEFT]
0 项奖励
回复

1,185 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by NXP_Europe on Fri Oct 28 17:13:06 MST 2011
Hello Mario

for details see the User Manual.

I am not sure ... or '/5000' or '/200' ...

[LEFT][SIZE=2][COLOR=#3f7f5f][FONT=Courier New][SIZE=1][COLOR=#3f7f5f]/* setup timer #0 for delay */[/COLOR][/SIZE][/FONT]
[/COLOR][/SIZE][SIZE=1][FONT=Courier New]LPC_TMR32B0->[/FONT][FONT=Courier New][COLOR=#0000c0][COLOR=#0000c0]TCR[/COLOR][/COLOR] = 0x02; [COLOR=#3f7f5f][COLOR=#3f7f5f]/* reset timer */[/COLOR][/COLOR][/FONT][/SIZE][COLOR=#3f7f5f]
[/COLOR][SIZE=1][FONT=Courier New]LPC_TMR32B0->[/FONT][FONT=Courier New][COLOR=#0000c0][COLOR=#0000c0]PR[/COLOR][/COLOR] = 0x00; [COLOR=#3f7f5f][COLOR=#3f7f5f]/* set [U]prescaler[/U] to zero */[/COLOR][/COLOR][/FONT][/SIZE][COLOR=#3f7f5f][/LEFT]
[/COLOR]
[LEFT][SIZE=1][FONT=Courier New]LPC_TMR32B0->[/FONT][FONT=Courier New][COLOR=#0000c0][COLOR=#0000c0]MR0[/COLOR][/COLOR] = delayInMs * ((SystemFrequency/LPC_SYSCON->[COLOR=#0000c0][COLOR=#0000c0]SYSAHBCLKDIV[/COLOR][/COLOR][/FONT][FONT=Courier New]) / 5000);[/FONT][/SIZE]
[SIZE=1][FONT=Courier New]LPC_TMR32B0->[/FONT][FONT=Courier New][COLOR=#0000c0][COLOR=#0000c0]MR0[/COLOR][/COLOR] = delayInMs * ((SystemFrequency/LPC_SYSCON->[COLOR=#0000c0][COLOR=#0000c0]SYSAHBCLKDIV[/COLOR][/COLOR][/FONT][FONT=Courier New]) / 200);[/FONT][/SIZE][/LEFT]

[LEFT][SIZE=1][FONT=Courier New]LPC_TMR32B0->[/FONT][FONT=Courier New][COLOR=#0000c0][COLOR=#0000c0]IR[/COLOR][/COLOR] = 0xff; [COLOR=#3f7f5f][COLOR=#3f7f5f]/* reset all [U]interrrupts[/U] */[/COLOR][/COLOR][/FONT][/SIZE][COLOR=#3f7f5f]
[/COLOR][SIZE=1][FONT=Courier New]LPC_TMR32B0->[/FONT][FONT=Courier New][COLOR=#0000c0][COLOR=#0000c0]MCR[/COLOR][/COLOR] = 0x04; [COLOR=#3f7f5f][COLOR=#3f7f5f]/* stop timer on match */[/COLOR][/COLOR][/FONT][/SIZE][COLOR=#3f7f5f][/LEFT]
[/COLOR][SIZE=1][FONT=Courier New]LPC_TMR32B0->[/FONT][FONT=Courier New][COLOR=#0000c0][COLOR=#0000c0]TCR[/COLOR][/COLOR] = 0x01; [SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* start timer */[/COLOR][/SIZE][/COLOR][/SIZE][/FONT][/SIZE]

[SIZE=1][FONT=Courier New][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f][SIZE=1][COLOR=#000000]delayInMs = steps of 200uS ...[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][/FONT][/SIZE]

[SIZE=1][FONT=Courier New][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f][SIZE=1][COLOR=#000000]Though I did not verify it in practice ... [/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][/FONT][/SIZE]
[SIZE=1][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE][/COLOR][/SIZE][/SIZE]
0 项奖励
回复

1,185 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed Oct 26 17:56:38 MST 2011
Is it too difficult to find a SysTick sample and change one line without spreadsheet :eek:

/* Systick rate is 1ms for timekeeping */
SysTick_Config(SystemCoreClock / 1000);
0 项奖励
回复