
QDK™
M16C/Neutrino-NC30
www.state-machine.com/m16c
5.2.2 Specifying Stack and Heap Sizes
This QDK-nano-M16C does not use the heap
1
uses only the Interrupt Stack and no User Stack.
Therefore, you disable the heap and set the User Stack size to zero. You need to declare adequate
stack size for the Interrupt Stack, which is the only stack used in this QDK-nano. In the C-startup
code, you specify the heap and stack sizes in the file
cstartdef.h
:
/* Modify the next line if you change the stack size */
#define __STACKSIZE__ 0x0
/* Modify the next line if you change the interrupt stack size */
#define __ISTACKSIZE__ 0x100
/* Modify the next line if you change the heap size */
#define __HEAPSIZE__ 0x0
/* Modify the next line if you change the standard I/O */
#define __STANDARD_IO__ 0
NOTE: The QK preemptive kernel generally requires more stack space than the cooperative
“Vanilla” kernel. You need to adjust the
__ISTACKSIZE__
value for your system.
5.3 The BSP header file bsp.h
(1) #include "sfr26a.h" /* special function registers for M16C/26A */
(2) #include "neutrinodef.h" /* M16C/NEUTRINO board interface */
/*--------------------------------------------------------------------------*/
(3) #define BSP_TICKS_PER_SEC 50
/*..........................................................................*/
void BSP_init(void);
void BSP_displyPhilStat(uint8_t n, char const *stat);
Listing 9 The bsp.h for the PELICAN crossing example.
(1) The header file “
sfr26a.h
” provides the definitions of the M16C/26A special function registers.
(2) The header file “neutrinodef
.h
” defines the interface to the NEUTRINO board.
(3) The BSP defines the desired ticking rate. This constant is useful for defining timeouts, which are
always specified in units of clock ticks.
5.4 BSP initialization
The following
BSP_init()
function from the PELICAN crossing application for the NEUTRINO board
configures the PIO lines for the User LEDs and the User switches, initializes the LCD, and the sys-
tem clock tick:
void BSP_init(void) {
uint16_t volatile delay;
1
Using the heap in real-time embedded devices can cause many problems, such as heap fragmentation, non-
determinism, concurrency issues, etc.
Copyright © Quantum Leaps, LLC. All Rights Reserved.
18 of 25
Comentarios a estos manuales