I am going through the noble quest of trying to run Chibios RT (3.0.2) without including HAL. I am also increasing the challenge by using Crossworks (GCC) as my compiler/debugger.
I have RT building and starting up (using Chibios startup and linker) on an STM32F405 dev board.
My code is currently the basic threaded LED blinker.
Code: Select all
#include "ch.h"
static THD_WORKING_AREA(waThread1, 128);
static THD_FUNCTION(Thread1, arg) {
(void)arg;
while (true)
{
GPIOC->ODR |= (1 << 12);
chThdSleepMilliseconds()(500);
GPIOC->ODR |= (0 << 12);
chThdSleepMilliseconds(500);
}
}
void
main(void)
{
chSysInit();
//
// SNIP (GPIO initialisation code)
//
chThdCreateStatic(waThread1, sizeof(waThread1), HIGHPRIO, Thread1, NULL);
while (true)
{
chThdSleepMilliseconds(500);
}
}
My chconf.h is setup to _not_ use tickless mode.
Code: Select all
#define CH_CFG_ST_RESOLUTION 32
#define CH_CFG_ST_FREQUENCY 10000
#define CH_CFG_ST_TIMEDELTA 0
#define CH_CFG_TIME_QUANTUM 0
#define CH_CFG_MEMCORE_SIZE 0
#define CH_CFG_NO_IDLE_THREAD FALSE
Basically I can never get the chThdSleepMilliseconds functions to return and continue processing. The code just loops through the "_idle_thread(void *p)" function.
I went through the HAL clock initialization code yesterday and played around with some different clock modes but nothing would help me progress.
My current thoughts are:
- Am I missing some sort of SysTick interrupt activation code? Because the idle thread is sitting there just doing the "port_wait_for_interrupt();" loop.
- I saw a few threads on the forum where people we sleeping in the main thread and this caused problems?
- Am I having some sort of stack issue? I have defined the following linker options:
--defsym=__main_stack_size__=0x1000
--defsym=__process_stack_size__=0x400
- I tried to look for how the OS attached to the SysTick timer but haven't found it yet.
Am I on the right track?
Any help would be much appreciated.
Mitch