From: Maarten B. <sou...@ds...> - 2005-03-31 19:34:30
|
Hi again Rod, Ok, if this is the case, then we definitely need to know if the latest snapshot gives you the same problems. If so, then we have a new bug, if not than this was fixed already and nothing stands in the way of a new release. > I forgot to place the initialisation lines like this: > > wCurTmr = ReadTimerTic(); > wOldTmr = wCurTmr; > > > These lines are just before the while 1.... > > I do not beleive that the bug report you quoted is relevant but I did not supply > enough infomation sorry about that. > > Rod > > On Fri Apr 1 1:08 , 'Maarten Brock' <sou...@ds...> sent: > > > > > > > > > > > > >Rod, > > > > > >This is a known bug (895992). The problem lies in the uninitialized > >variables. The liverange analysis doesn't correctly detect these > >variables to be alive at the start of the loop. Initialize them and try again > >please. > > > > > >> All, > >> > >> I have been trying to get my main loop to run correctly. I have been > >> having trouble with the following code: > >> > >> void main( void ) > >> { > >> UINT16 wOldTmr; > >> UINT16 wCurTmr; > >> > >> while( 1 ) > >> { > >> while( wOldTmr == wCurTmr ) > >> { > >> wCurTmr = ReadTimerTic(); > >> } > >> wOldTmr = wCurTmr; > >> > >> /* Some more code here */ > >> } > >> > >> The function ReadTimerTic returns a 16-bit value my problem was that > >> this loop at the top of main was supposed to delay 1mS so my main loop > >> would run every 1mS. This is not the case it seems that the optomizer > >> is allowing the loop to exit immediately without delaying 1mS. It was > >> not until I set both variables to volatile that the loop run correctly. > >> I have no problem with this but the definition of volatile is to tell > >> the compiler to reload a variable on each reference to the variable in > >> case of a change in value outside the main program flow. In this case > >> the variable wCurTmr will change but that change is in sync with the > >> normal program flow. So my question is whey do I have to have the > >> volatile declaration in any case? This would seem to me to be a case of > >> an over aggressive optomizer. I have never had to do this with the Keil > >> compiler so I was surprised when I did this with SDCC. > >> > >> My code is all working now and I have very happy but I would clasify > >> this as unexpected and nothing else. > >> My version of sdcc is: > >> SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 > >> 2.4.0 (Mar 22 2005) (UNIX) > >> > >> Regards, > >> Rod Boyce > > > > > > > >Greets, > >Maarten > > > > > > > > > > > >------------------------------------------------------- > >This SF.net email is sponsored by Demarc: > >A global provider of Threat Management Solutions. > >Download our HomeAdmin security software for free today! > >http://www.demarc.com/info/Sentarus/hamr30 > >_______________________________________________ > >Sdcc-user mailing list > >Sdc...@li... > >https://lists.sourceforge.net/lists/listinfo/sdcc-user > > > > > ------------------------------------------------------- > This SF.net email is sponsored by Demarc: > A global provider of Threat Management Solutions. > Download our HomeAdmin security software for free today! > http://www.demarc.com/info/Sentarus/hamr30 > _______________________________________________ > Sdcc-user mailing list > Sdc...@li... > https://lists.sourceforge.net/lists/listinfo/sdcc-user > > |