bugGNU Development Chain for 68HC11/68HC12 - Bugs: bug #16626, wrong code on 68hcs12

 
 

You are not allowed to post comments on this tracker with your current authentification level.

bug #16626: wrong code on 68hcs12

Submitted by:  None
Submitted on:  Fri 19 May 2006 08:23:01 AM UTC  
 
Category: gccSeverity: 3 - Normal
Item Group: sw-bugStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Open

Fri 19 May 2006 08:23:01 AM UTC, original submission:

I don't know if it is a bug or not.

I have problem with the following short code segment.

After the start of program the tickcount is increased every 10 ms by a timer interrupt. All seems to by ok and DoSoemthing() is called every 50 tickcounts. But if the tickcount goes from 0x7fff to 0x8000 then DoSomething() is called many times (as fast as possible). This iterate on each changing of tickcount from 0x7fff to 0x8000.
The bug occurs only on a 68hcs12 and it runs ok on a 68hc12 processor. (gcc 2.95) The assmbler output is the same for 68hc12 and 68hcs12.

extern void DoSomething();

static short tickCount = 0;

void TriggerEvent(void) {
static short nextTickTime = 0;

if (nextTickTime - tickCount <= 0) {
nextTickTime += 50;
// to do something
DoSomething();
}
}

# assembler output
TriggerEvent:
ldx nextTickTime.0
tfr x,d
subd tickCount
bgt .L1
tfr x,d
addd #50
std nextTickTime.0
bsr DoSomething
.L1:
rts

Anonymous

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

No Changes Have Been Made to This Item

Back to the top


Powered by Savane 3.1-cleanup