Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 4 months ago.
Enable systick for Cortex-M4 Tiva C
Hello, I am porting mbed OS for Tiva C launchpad TM4C123G, I have added CMSIS files, and currently implementing Target/HAL files I am just starting with minimum requirements by enabling GPIOs in device.h.
The problem is, after flashing my code to the MCU, OS jumps to "Hard Fault handler". It doesn't go there unless I configured function
us_ticker_set_interrupt
here's how file us_ticker.c looks like
#include <stddef.h> #include "us_ticker_api.h" #include "core_cm4.h" int us_ticker_inited = 0; void us_ticker_init(void) { if (us_ticker_inited) return; us_ticker_inited = 1; (void)SysTick_Config(80); NVIC_SetVector(SysTick_IRQn, (uint32_t)us_ticker_irq_handler); NVIC_EnableIRQ(SysTick_IRQn); } /** Read the current counter * * @return The current timer's counter value in microseconds */ uint32_t us_ticker_read() { uint32_t return_ticks; if (!us_ticker_inited) us_ticker_init(); return_ticks = SysTick->VAL; return return_ticks; } /** Disable us ticker interrupt * */ void us_ticker_disable_interrupt(void) { SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk; /* Disable SysTick IRQ and SysTick Timer */ } /** Clear us ticker interrupt * */ void us_ticker_clear_interrupt(void) { //Systick is automatically cleared when interrupt is served } /** Set interrupt for specified timestamp * * @param timestamp The time in microseconds to be set */ void us_ticker_set_interrupt(timestamp_t timestamp) { uint32_t ticks = (80*timestamp)&SysTick_CALIB_TENMS_Msk; SysTick->LOAD = ticks - 1; SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk; /* Enable SysTick IRQ and SysTick Timer */ }
I have configured PLL to supply 80MHz, so for every 80 ticks, the processor spends 1us. I am using GCC compiler, my IDE is Eclipse,
Any hint where should I debug? or what am i doing wrong here?