Remember that templates are code substitution. I think what's going on here is 
that `AHB1ENR` returns `volatileLoad(RCC_AHB1ENR)`, this is a statement which 
resolves to the type `RCC_AHB1ENR_Val`. Now in `GPIOAEN` this is used once in 
the emit statement which causes a read, then it is passed on to the `write`. 
Then in the `write` it is essentially expanded as `volatileStore(RCC_AHB1ENR, 
volatileLoad(RCC_AHB1ENR))` causing your second incorrect read. If you change 
`AHB1ENR` to:
    
    
    proc AHB1ENR*(base: static RCC_Base): RCC_AHB1ENR_Val {.inline.} =
      volatileLoad(RCC_AHB1ENR)
    
    
    Run

Then I think this issue should be gone as what you're passing along now is the 
actual value and not the statement which resolves to a value.

Reply via email to