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
> Even the following code uses the value which has been read
> before the cycle:
>
> uint8_t r= FLASH->iapsr & 5;
> while ((FLASH->iapsr & 5) == 0) ...
This one is a bug. I'll file a bug erport.
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user