Hello Maarten,

so far I observed it only for the ADC result register (ADC_DR) for read, and 
timer 3 compare register (TIM3_CCR) for write. The way I realized was simple: 
the ADC the result was skewed, and the TIM3 period was wrong. However, I didn’t 
dig deeper after I found out that changing the sequence helps.

At least for ADC_DR there is a hint in the STM8 reference manual 
(http://www.st.com/web/en/resource/technical/document/reference_manual/CD00190271.pdf,
 page 425): "The conversion results from ADC_DRH and ADC_DRL data registers 
must be read in a specific order to guarantee data coherency. This order 
depends on the data alignment“. For TIM3_CCR I couldn’t find any such hint :-(

As for automatically supporting it in SDCC I am skeptical:
1) apparently changing the alignment in the ADC also changes the read sequence 
(see above). And for the other registers I just don’t know —> how could you 
account for that?
2) if at all, I’d only support WORD read/write. Because when somebody performs 
bytewise r/w operation, he/she expects the compiler to do exactly that. They 
might be doing some advance trick (which is beyond me), and changing the 
sequence might do more harm than good
In my STM8 header file I will now implement WORD read and write macros for 
convenience. And if someone e.g. changes ADC alignment he/she can easily swap 
the order in the macro. However, that requires that this "feature“ is 
understood and well documented...

Talking of understood: do you have any idea how I can check any register 
without a debugger, let alone all? For the above mentioned it was plain 
obvious, because the STM8 clearly didn’t behave as expected. But there are too 
many 16b SFR registers with sometimes minute effect on the STM8 behavior to 
check them via their functionality alone. Any idea is appreciated!

Regards, Georg I.



> ------------------------------
> 
> Message: 7
> Date: Fri, 18 Apr 2014 09:49:36 +0200 (CEST)
> From: "Maarten Brock" <sourceforge.br...@dse.nl>
> Subject: Re: [Sdcc-user] r/w order for STM8 16b registers
> To: sdcc-user@lists.sourceforge.net
> Message-ID: <42447.82.161.160.72.1397807376.squir...@www.dse.nl>
> Content-Type: text/plain;charset=iso-8859-1
> 
> Hello Georg,
> 
> Is this behaviour true for all 16 bit SFR's? Or is it different for every
> other SFR? If it's always the same then maybe SDCC could take this into
> account.
> 
> Maarten
> 
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to