Am 22.10.2017 um 20:26 schrieb Maarten Brock:
> Hello,
> 
>> Am 18.07.2017 um 16:59 schrieb Daniel Drotos:
>>>
>>> Hi,
>>>
>>> I'm using sdcc-stm8 with following code:
>>>
>>> struct FLASH_t { ... ; volatile uint8_t iapsr; ...};
>>> #define FLASH ((struct FLASH_t *)BASE_ADDRESS_OF_FLASH_CONTROLLER)
>>>
>>> Program waits end of flash operation in a busy loop:
>>>
>>> while ((FLASH->iapsr & 5) == 0) ...;
>>>
>>> it works well rereading value of iapsr in every check. But in following
>>> structure:
>>>
>>> uint8_t r= FLASH->iapsr;
>>> while ((r & 5) == 0)
>>>   r= FLASH->iapsr;
>>>
>>> iapsr is read just once and the cycle uses that value without rereading
>>> the register.
>>
>> As it should. FLASH->iapsr is read one, the result assinged to r. The
>> while only depends on r, not FLASH->iapsr
> 
> I don't think so. It should read FLASH->iapsr into r on every loop and
> reevaluate r.
> 
> Maarten
> 

Ah, sorry. Somehow I missed the assignment to r inside the loop. Anyway,
in that case this is most likely the same bug as #2673 that I just
opened, so this case will be fixed, too when #2673 gets fixed.

Philipp

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to