Firmware: clean up clock/timer init

This commit is contained in:
Maximilian Rehkopf 2012-11-07 09:44:50 +01:00
parent fee97e5016
commit b67e2a5c77
4 changed files with 13 additions and 5 deletions

View File

@ -27,7 +27,7 @@ void clock_init() {
-> FPGA freq = 11289473.7Hz
First, disable and disconnect PLL0.
*/
// clock_disconnect();
clock_disconnect();
/* PLL is disabled and disconnected. setup PCLK NOW as it cannot be changed
reliably with PLL0 connected.
@ -74,7 +74,7 @@ void disablePLL0() {
}
void connectPLL0() {
while(!(LPC_SC->PLL0STAT&PLOCK0));
while(!(LPC_SC->PLL0STAT & PLOCK0));
LPC_SC->PLL0CON |= PLLC0;
PLL0feed();
}

View File

@ -74,6 +74,4 @@ void disableMainOsc(void);
void PLL0feed(void);
void setClkSrc(uint8_t src);
#endif

View File

@ -88,7 +88,9 @@ printf("PCONP=%lx\n", LPC_SC->PCONP);
file_init();
cic_init(0);
/* setup timer (fpga clk) */
LPC_TIM3->TCR=2;
LPC_TIM3->CTCR=0;
LPC_TIM3->PR=0;
LPC_TIM3->EMR=EMC0TOGGLE;
LPC_TIM3->MCR=MR0R;
LPC_TIM3->MR0=1;

View File

@ -57,9 +57,17 @@ void timer_init(void) {
/* clear RIT mask */
LPC_RIT->RIMASK = 0; /*xffffffff;*/
/* PCLK = CCLK */
/* PCLK_RIT = CCLK */
BITBAND(LPC_SC->PCLKSEL1, 27) = 0;
BITBAND(LPC_SC->PCLKSEL1, 26) = 1;
/* PCLK_TIMER3 = CCLK/4 */
BITBAND(LPC_SC->PCLKSEL1, 15) = 0;
BITBAND(LPC_SC->PCLKSEL1, 14) = 0;
/* enable timer 3 */
BITBAND(LPC_SC->PCLKSEL1, PCLK_TIMER3) = 1;
/* enable SysTick */
SysTick_Config((SysTick->CALIB & SysTick_CALIB_TENMS_Msk));
}