Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

not-a-bug? signed counter not counting

2 posters

Go down  Message [Page 1 of 1]

1not-a-bug? signed counter not counting Empty not-a-bug? signed counter not counting Fri Jan 14, 2022 10:33 pm

TimFisch

TimFisch

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..  scratch  scratch

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
not-a-bug? signed counter not counting Attachmentshort.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).)

https://wiki.mexle.hs-heilbronn.de/

2not-a-bug? signed counter not counting Empty Re: not-a-bug? signed counter not counting Fri Jan 14, 2022 11:18 pm

arcachofo

arcachofo

Looks more like a kind of compiler problem. But could also be related to Simu
Most probably an error in simulide.

I will have a look.

arcachofo

arcachofo

Solved in Rev 852.

Btw... Big thanks to your students!!

Sponsored content



Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum