Some of my students are kind of creative and tried to declare a counter as a "short" in Microchip studio (gcc). Not a problem, I thought. But somehow the "short" counter is not able to count up. A counter as "unsigned short" works - and even more strange: Once a counter as "unsigned short" is used also another as "signed" works then, too..
Looks more like a kind of compiler problem. But could also be related to Simu:
the "short" counter gets the "if" compiled into assembler instruction "brlt", for the working "unsigned short" it gets "brcs". I'm not so familiar with AVR assembler. :-/
hex files and sim1 (V 1.0.0-R815) is attached.
Looks more like a kind of compiler problem. But could also be related to Simu:
the "short" counter gets the "if" compiled into assembler instruction "brlt", for the working "unsigned short" it gets "brcs". I'm not so familiar with AVR assembler. :-/
hex files and sim1 (V 1.0.0-R815) is attached.
- Code:
#include <avr/io.h>
short not_working = 1;
//unsigned short working = 0;
int main()
{
while(1)
{
++not_working;
OCR0A = not_working;
if (not_working > 3) not_working = 0;
//++working;
//OCR2A = working;
//if (working > 3) working = 0;
}
return 0;
}
- Attachments
- short.zip
- You don't have permission to download attachments.
- (2 Kb) Downloaded 1 times
Last edited by arcachofo on Sat Jan 15, 2022 1:02 am; edited 1 time in total (Reason for editing : Marked as solved (green color).)