On Fri, 18 Apr 2014, Georg Icking-Konert wrote:

> 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=92t 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/CD0=
> 0190271.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 :-(

The introductory section for TIM3 states:

   Only the main features of the general purpose timers are given in this
   chapter. Refer to the corresponding paragraphs of Section 17: 16-bit
   advanced control timer (TIM1) on page 136 for more details on each
   feature.

Looking back through that section I see that sections 17.5-17.5.1 (page 
164) describes reading and writing the TIM1_CCRi registers. It states

   16-bit values are loaded in the TIM1_CCRi registers through preload
   registers. This must be performed by two write instructions, one for
   each byte. The MS byte must be written first.

The sequence for reading the TIM1_CCRi register is also shown as MS byte 
then LS byte.

So the byte ordering is not an issue of read versus write, but simply an 
idiosyncrasy of the particular peripheral subsystem.

   Erik


------------------------------------------------------------------------------
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