Hello guys, I have been programming an ATMEGA16 using Atmel Studio 7 in assembly so far and I am now moving in C. The project I am on is not that hard but I fell into a minor problem. I have a simple function that takes a 16bit uint and only contains a switch. I noticed that it only works for the cases that involve the 8 LSB of the 16bit uint while every other case just goes to default. I suppose this has to do with the fact that ATMEGA16 is an 8bit controller and the switch involves a comparison which only occurs for the 8 LSB. Of course the simple solution would be converting my 16bit number into 2 8bit numbers and having 2 switches instead. So my questions are:
1) Atmel Studio really does not support comparisons with 16bit integers or it can be done with maybe some type casting?(I did try some type castings but I seemed to get the same result every time)
2) If it is not supported is there a smarter way than converting the number into 2 8bit numbers?
3) Is there an option that makes it show warnings for that? (which in my opinion should show up in the first place)
I am also attaching my code. Thanks for your time!
uint8_t keypad_to_ascii_single_switch(uint16_t keyspressed) { switch(keyspressed) { case 0x0001: return 'E'; case 0x0002: return '0'; case 0x0004: return 'F'; case 0x0008: return 'D'; case 0x0010: return '7'; case 0x0020: return '8'; case 0x0040: return '9'; case 0x0080: return 'C'; case 0x0100: return '4'; case 0x0200: return '5'; case 0x0400: return '6'; case 0x0800: return 'B'; case 0x1000: return '1'; case 0x2000: return '2'; case 0x4000: return '3'; case 0x8000: return 'A'; default: return 0; } }