Giovanni,
I worked through the GPT Driver and have continuous timers running.
In testing the RTC Driver, I enable it, and set a 10 sec continuous timer, with the callback to simply call rtcGetTime and report it. If I use
chprintf((BaseChannel *)&SD2,"m:s %d:%d\r\n", minute, second);
the time is reported from COM2 as expected. If I use
chprintf((BaseChannel *)&SD2,"d:h:m:s %d:%d:%d:%d\r\n", day, hour, minute, second);
the code hangs without displaying the first time string. ie the length of the string triggers the crash in some way.
Some USB activity is occuring with Windows trying to query an unknown device, and might be related. Is it that calling chprintf from a callback is the problem? It almost seems that chprintf is not completing before something else trips it.
Suggestions?
DOC Correction: In Real Time Clock Abstraction Layer, it reads
"than disable RTC_SUPPORTS_CALLBACKS option in halconf.h"
This should be "then disable RTC_SUPPORTS_CALLBACKS option in os\hal\platforms\STM32\RTCv1\rtc_lld.h"
GPT Event, and callbacks
Moderators: RoccoMarco, lbednarz, tfAteba
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: GPT Event, and callbacks
Hi,
The problem is not calling chprintf() from a callback, it is calling the serial driver functions from a callback. From callbacks only I-Class functions can be used. If you enable the state checker in chconf.h it will trap all this kind of errors.
Thanks for finding the error, I'll fix it.
Giovanni
The problem is not calling chprintf() from a callback, it is calling the serial driver functions from a callback. From callbacks only I-Class functions can be used. If you enable the state checker in chconf.h it will trap all this kind of errors.
Thanks for finding the error, I'll fix it.
Giovanni
Re: GPT Event, and callbacks
OK, I see the issue with I-class functions.
More DOC corrections or clarifications for RTC Driver
The typedef struct RTCTime RTCTime; at line 70 in rtc.h is just a stub.
It's actually defined in os\hal\platforms\STM32\RTCv1\rtc_lld.h line 96 as
struct RTCTime {
/**
* @brief Seconds since UNIX epoch.
*/
uint32_t tv_sec;
/**
* @brief Fractional part.
*/
uint32_t tv_msec;
};
I see in rtc_lld.c how the RTCTime struct is encoded/decoded. If I understand correctly the Date/Time bit masks (RTC_TIME_SECONDS_MASK etc) apply to decoding struct member tv_sec. The rtc_lld_set_time notes say "the Fractional part is silently ignored."
Because the Seconds field is 5 bits (0-31), do I assume that the STM32F1xx RTC has 2 second accuracy, so when setting the Second field, the actual value should be divided by 2?
SD
More DOC corrections or clarifications for RTC Driver
The typedef struct RTCTime RTCTime; at line 70 in rtc.h is just a stub.
It's actually defined in os\hal\platforms\STM32\RTCv1\rtc_lld.h line 96 as
struct RTCTime {
/**
* @brief Seconds since UNIX epoch.
*/
uint32_t tv_sec;
/**
* @brief Fractional part.
*/
uint32_t tv_msec;
};
I see in rtc_lld.c how the RTCTime struct is encoded/decoded. If I understand correctly the Date/Time bit masks (RTC_TIME_SECONDS_MASK etc) apply to decoding struct member tv_sec. The rtc_lld_set_time notes say "the Fractional part is silently ignored."
Because the Seconds field is 5 bits (0-31), do I assume that the STM32F1xx RTC has 2 second accuracy, so when setting the Second field, the actual value should be divided by 2?
SD
Re: GPT Event, and callbacks
Hi rallysjd,
That masks used to decode time values from MCUs with hardware calendar (F4x, F2x, L1x) and not tested yet. On F1x platform there is simple 32-bit second counter, that you can tune with 1 second accuracy. There is no way to set time with subsecond accuracy on any STM32 platform.
rallysjd wrote: If I understand correctly the Date/Time bit masks (RTC_TIME_SECONDS_MASK etc) apply to decoding struct member tv_sec.
That masks used to decode time values from MCUs with hardware calendar (F4x, F2x, L1x) and not tested yet. On F1x platform there is simple 32-bit second counter, that you can tune with 1 second accuracy. There is no way to set time with subsecond accuracy on any STM32 platform.
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: GPT Event, and callbacks
Barthess is correct, those masks were meant for a DOS-format conversion routine, I'll remove them until the functionality is added.
The current implementation is simply a seconds counter (Unix-like). You can set an arbitrary zero time and then perform conversions.
Giovanni
The current implementation is simply a seconds counter (Unix-like). You can set an arbitrary zero time and then perform conversions.
Giovanni