GPT Event, and callbacks

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
rallysjd
Posts: 15
Joined: Mon Jan 16, 2012 4:17 pm

GPT Event, and callbacks

Post by rallysjd »

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"
User avatar
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

Post by Giovanni »

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
rallysjd
Posts: 15
Joined: Mon Jan 16, 2012 4:17 pm

Re: GPT Event, and callbacks

Post by rallysjd »

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
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: GPT Event, and callbacks

Post by barthess »

Hi rallysjd,
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.
User avatar
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

Post by Giovanni »

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
Post Reply