Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By Leandro Zimmer
#59237 Hi,

https://github.com/esp8266/Arduino/blob ... PI/SPI.cpp

Code: Select all/**
 * Note:
 *  in and out need to be aligned to 32Bit
 *  or you get an Fatal exception (9)
 * @param out uint8_t *
 * @param in  uint8_t *
 * @param size uint32_t
 */
void SPIClass::transferBytes(uint8_t * out, uint8_t * in, uint32_t size) {
    while(size) {
        if(size > 64) {
            transferBytes_(out, in, 64);
            size -= 64;
            if(out) out += 64;
            if(in) in += 64;
        } else {
            transferBytes_(out, in, size);
            size = 0;
        }
    }
}


"in and out need to be aligned to 32Bit"

How I do to align bits?
User avatar
By martinayotte
#59248 Are those arrays been local variables ?
Because I don't think you even need to bother about alignment, since variables created on stack are supposed to be aligned already to 32 bits.
You can verify that by printing their starting address using printf("%p", &in[0]);
If address are not rounded at 4, then you can try :
uint8_t in[3] __attribute__((aligned(4)));