- Fri Nov 18, 2016 12:26 pm
#58328
rith87 wrote:I see a few warnings in the SDK documentation:
We suggest using a timer to check periodically, if users need to call os_delay_us or
function while, or function for in timer callback, please do not occupy CPU more than 15
ms.
Does the latter mean that there is a 15 ms time limit even for software timer callbacks? Why 15 ms?
Yes, it does. The ESP8266 only has a single core and the non-os SDK is only single threaded. The device is not just running your code, it's also running other stuff, like keeping the WiFi association(s) alive. I assume 15ms is, give or take, how frequently it needs to do this.
Read and write RAM has to be aligned by 4 bytes, so please do not cast pointer directly,
for example, please use os_memcpy instead of float temp = *((float*)data);.
Does this apply only if data was some (void *) or (uint8_t *)? Or do they mean that assignment to a dereferenced pointer is invalid? (i.e if data was a float * already, is it still invalid? seem crazy if it is...)
What this is essentially saying is that when accessing some data types, these must be aligned on a 4-byte boundary in RAM. This applies to for example a 4 byte int type. So if you cast an arbitrary piece of memory to an int there a 3 in 4 chance this won't be 4 byte aligned, so the processor will throw an exception.
In reality it may be much less likely, or much more likely, than 3 in 4 depending on the precise code - or it may not happen at all.
You can resolve your problem by declaring your buf to be 4 byte aligned:
Code: Select alluint8_t __attribute__((aligned(4))) buf[100];