ChRt
ChRt copied to clipboard
Teensy 4.0 support?
Hello,
I tried a quick and dirty mod to get things up with Teensy 4.0 but I didn't succeed so far.
Would it be difficult to support also Teensy 4.0 (which has its RAM splitted in two zones)?
Would it need adapations of ChRt-master\src\teensy3 files only?
Best regards
Support for Teensy 4.0 requires mods to other files since it is a Cortex M7 processor. The mods are to files in various folders.
I am not sure when I will tackle Teensy 4.0 since I would start with the latest version of ChibiOS so I have the latest Cortex M7F support in CMSIS.
I have been looking at the latest ChibiOS 19.3. It really looks good.
I wish I could port it in tickless mode to Arduino style boards. This allows better time resolution with no overhead unless you use a feature.
The point is the Arduino IDE, libs, and the accessibility. Other would say move away to another IDE and use ChibiOS source code, but that would mean much more difficulties to get things running on an Arduino or a Teensy (the Teensy 4.0 introducing nice new features, like digital audio).
Thanks for your efforts.
Try the new release. It has Teensy 4.0 support with both periodic and tick-less modes.
http://www.chibios.org/dokuwiki/doku.php?id=chibios:articles:tickless
The Teensy 4.0 GPT timer exactly matches the requirement for tick-less mode. Most timer functions are a single line of code.
Here is the ChibiOS GPT2 functions. I couldn't believe how simple they are.
/**
* @brief Returns the time counter value.
*
* @return The counter value.
*
* @notapi
*/
static inline systime_t st_lld_get_counter(void) {
return (systime_t)GPT2_CNT;
}
/**
* @brief Starts the alarm.
* @note Makes sure that no spurious alarms are triggered after
* this call.
*
* @param[in] time the time to be set for the first alarm
*
* @notapi
*/
static inline void st_lld_start_alarm(systime_t time) {
GPT2_OCR1 = (uint32_t)time;
GPT2_SR |= GPT_SR_OF1;
GPT2_IR = GPT_IR_OF1IE;
}
/**
* @brief Stops the alarm interrupt.
*
* @notapi
*/
static inline void st_lld_stop_alarm(void) {
GPT2_IR = 0;
}
/**
* @brief Sets the alarm time.
*
* @param[in] time the time to be set for the next alarm
*
* @notapi
*/
static inline void st_lld_set_alarm(systime_t time) {
GPT2_OCR1 = (uint32_t)time;
}
/**
* @brief Returns the current alarm time.
*
* @return The currently set alarm time.
*
* @notapi
*/
static inline systime_t st_lld_get_alarm(void) {
return (systime_t)GPT2_OCR1;
}
/**
* @brief Determines if the alarm is active.
*
* @return The alarm status.
* @retval false if the alarm is not active.
* @retval true is the alarm is active
*
* @notapi
*/
static inline bool st_lld_is_alarm_active(void) {
return (GPT2_IR & GPT_SR_OF1) != 0;
}
Hi @greiman It seems that latest Teensiduino doesn't work with your lib. I thought its because something in the GPT2 Timer configuration is now off. But I cant seem to make the periodic work as well.
Looks like a conflict that causes a lockup. I will look at it more when I have time.
Try the latest update. I think I found the problem.
Paul added a 32 byte protected region between bss and the stack. I fill the stack with 0X55 and the new region caused a memory protection fault.
I set stack low address to &_ebss + 32. Hope Paul doesn't change that since there is no symbol for stack low address.
The stack overflow region is a great idea, worth breaking ChRt.
Firstly I tried the 1.2.0 from platformio, and I was unable to get it to work on the Teensy 4.1. But after I pulled the library directly from here, it worked like a charm. So it looks like the fix is working 👍
I have tried the same thing as @BoMadsen suggested, and it fixed the problem. It seems that platformio build is not working, but direct pull from this repo works.
By the way, Thank you very much @greiman for this amazing library!