
QDK™
M16C/Neutrino-NC30
www.state-machine.com/m16c
/* initialize the clock... */
prc1 = 1; /* enable access to processor mode registers */
pm20 = 0; /* 2 wait states for SFR access for >16MHz operation... */
prc1 = 0; /* disable access to processor mode registers */
/* configure PLL, must be consistent with f1_CLK_HZ */
prc0 = 1; /* enable access to clock registers */
cm1 = 0x20; /* set to hi-drive Xin, divide by 1 */
cm0 = 0x08; /* set to main clock using divide by 1 */
cm21 = 0; /* switch to Xin */
plc0 = 0x12; /* configure PLL to x4 */
plc0 = 0x92; /* enable PLL */
for (delay = 20000; delay != 0; --delay) { /* wait for stable PLL */
}
cm11 = 1; /* switch to PLL */
prc0 = 0; /* disable access to clock registers */
/* enable the User LEDs */
// LED0_DDR = 1; /* pins used by UART2 */
// LED1_DDR = 1;
LED2_DDR = 1;
LED3_DDR = 1;
// LED0 = LED_OFF;
// LED1 = LED_OFF;
LED2 = LED_OFF;
LED3 = LED_OFF;
/* configure Switch pins as inputs... */
SW1_DDR = 0;
/* configure 32kHz sub clock..., see NOTE02 */
pd8_7 = 0; /* set GPIO to inputs (XCin/XCout) */
pd8_6 = 0;
prc0 = 1; /* unlock CM0 and CM1 */
cm04 = 1; /* start the 32KHz crystal */
prc0 = 0; /* lock the System Clock Control Register */
/* setup Timer A running from fc32... */
ta0mr = 0xC0; /* Timer mode, fc32, no pulse output */
ta0 = (int)((fc_CLK_HZ/32 + BSP_TICKS_PER_SEC/2)
/ BSP_TICKS_PER_SEC) - 1; /* period */
ta0ic = TICK_ISR_PRIO; /* set the clock tick interrupt priority level */
}
5.5 Starting Interrupts in QF_onStartup()
QP-nano invokes the
QF_onStartup()
callback just before starting the event loop inside
QF_run()
.
The
QF_onStartup()
function must start the interrupts configured earlier. In this BSP only the sys-
tem tick interrupt is started.
void QF_onStartup(void) {
ta0s = 1; /* Start timer A0 */
}
Listing 10 Configuring and enabling interrupts in the
QF_onStartup()
callback.
5.6 Assertion Handling Policy in Q_onAssert()
As described in Chapter 6 of [PSiCC2], all QP components use internally assertions to detect errors
in the way application is using the QP services. You need to define how the application reacts in
Copyright © Quantum Leaps, LLC. All Rights Reserved.
19 of 25
Comentarios a estos manuales