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:
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?
Yeah... I get it now - I guess I really misunderstood using a typecast and shifting at the same time, thanks for clearing that up. I must have added this at some point and can't remember.
I'm still confused why I'm not getting the same warning on the read_eeprom() function though...
EDIT....
Actually, I just figured out where I failed... it was supposed to be:
RicThot:
Not really the code, typed in by hand in my post
For future reference, when posting code it's always best to post code that actually compiles and shows the problem. (If the sections of code that were represented by ... were not needed to show the problem, you could have simply left out the elided code completely.)