From: Tomaž Š. <tom...@ij...> - 2012-03-16 09:42:35
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi First, I apologize for the amount of patches I'm sending to this list. Please tell me, if you prefer some other way I can contribute them to libopencm3. I have some code that looks like this: rtc_set_counter_val(0) while(...) { int timestamp = rtc_get_counter_val() ... some time consuming operation ... } The problem is that there is a race condition since rtc_set_counter_val() doesn't wait for the RTC register write to finish so timestamp might be set to the uninitialized value of the RTC counter on the first iteration. Although I can fix this in my code I think this is a somewhat surprising result of using libopencm3 RTC functions. rtc_set_counter_val() should wait until the RTC actually gets updated before returning. There is code in rtc_exit_config_mode() that does just that, but is commented out with "Unnecessary since we poll the bit on config entry(?)". I think code above is one example, where this might be necessary. Best regards Tomaž - -- Tomaž Šolc, research assistant SensorLab, Jožef Stefan Institute http://sensorlab.ijs.si mail: tom...@ij... blog: http://www.tablix.org/~avian/blog -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJPYwr2AAoJED848b3tOBsIqtgH/1lmxb2BxbQLG1R9fwh9gLGW Ng/CoSI5rOeMCGDnVcM2MwJ/bddNtQqAqobgA1+XEFha+V2rjg+7DahJ+9xo4wlj R+IeRfihr/GtfEqMHl5a58q4IEFchC/xDLV8qkNGIN2VaIhVKfyhWCH0/hfxkhpY wAjDJyMC4rDYfmkF59DMuDTYlJSLkliWSBaqQwIgfrcg4q/VM3JvAr84rmHPOGBr j+uJTv0GZTXxmIEjFeNTvV26iSTZE9lYaGv/94I3HNlBqsVPR5D2Jt2GlxLWEtlo MXy+gfU2ZQhIQwfhJDmusu+GZ4IxhiPeJdYNHnGkVrF3kEY+cDfuWkS/fCynQRA= =A83y -----END PGP SIGNATURE----- |