Hi guys,
I'm a pretty confused newbie right now. Not sure what happened with my code but it was working flawlessly until (???) happened - then I started getting weird results on the serial monitor and noticed 2 warnings when my code compile, which I didn't notice before, I'm wondering if that could explain the mess.
My code is pretty simple, it reads/erase/write bytes from/to an EEPROM chip (Winbond W25Q16BV).
I have 3 'address' variables, declared and initilialized as follow:
void loop()
{
unsigned long read_address;
unsigned long erase_address;
unsigned long write_address;
...some code...
erase_address = 0;
erase_eeprom(erase_address);
write_address = 0;
write_eeprom(write_address);
read_address = 0;
read_eeprom(read_address);
...more code...
}
void erase_eeprom(unsigned long address)
{
...
spi((byte)address>>16); //MSB
spi((byte)address>>8);
spi((byte)address); //LSB
...
}
void write_eeprom(unsigned long address)
{
...
spi((byte)address>>16); //MSB
spi((byte)address>>8);
spi((byte)address); //LSB
...
}
void read_eeprom(unsigned long address)
{
...
spi((byte)address>>16); //MSB
spi((byte)address>>8);
spi((byte)address); //LSB
...
}
All 3 functions handles the unsigned long address pretty much the same way, but I'm getting right shift warnings on the erase and write function and I can't figure out why:
W25Q16BV_readv2.ino: In function 'void sector_erase(long unsigned int)':
W25Q16BV_readv2.ino:174: warning: right shift count >= width of type
W25Q16BV_readv2.ino: In function 'void write_eeprom(long unsigned int, byte)':
W25Q16BV_readv2.ino:186: warning: right shift count >= width of type
As far as I know, an unsigned long is 4bytes/32bits... why would I get this warning when right shifting 16 bits ?
And why am I getting the warning only on those 2, but not the read_eeprom function?