gicking / STM8_templates

STM8 Libraries and Examples with Arduino look&feel
Apache License 2.0
23 stars 7 forks source link

PCKENR1 bit order is reversed #3

Closed blkhawk closed 6 years ago

blkhawk commented 6 years ago

Found another one. Unless the stm8l152 I am working with is a reversed bit order the order of control bits is revered in your definition. This affects other registers as well.

Timer 3 is working for me now.

/* Peripheral clock gating register 1 (CLK_PCKENR1) / union { /// bytewise access to register uint8_t byte; /// bitwise access to register struct { uint8_t PCKEN_TIM1 : 1; ///< clock enable TIM1 uint8_t PCKEN_TIM3 : 1; ///< clock enable TIM3 uint8_t PCKEN_TIM2_TIM5 : 1; ///< clock enable TIM4/TIM6 uint8_t PCKEN_TIM4_TIM6 : 1; ///< clock enable TIM4/TIM6 uint8_t PCKEN_UART2 : 1; ///< clock enable UART2 uint8_t PCKEN_UART1 : 1; ///< clock enable UART1 uint8_t PCKEN_SPI : 1; ///< clock enable SPI uint8_t PCKEN_I2C : 1; ///< clock enable I2C } reg; } PCKENR1;

gicking commented 6 years ago

Hello blkhawk,

checking the reference manuals for STM8S / STM8A (RM0016) and STM8L (RM0031) I realized the are big differences (at least) in the CLK_PCKENR* registers :-( I guess (hope) that this is the cause of the issue you observed, and not a completely different handling of SFRs…

As for a solution: in mid-term I plan to develop device headers also for the non-STM8S/A families. Looking to the SPL by STM I guess I will end up with 4 different header files. Unfortunately that doesn’t help you today…

blkhawk commented 6 years ago

Ah, because the order was there and exactly reverse I assumed it was a transcription mistake. Please close the issue - my mistake. Should have figured that there were some changes after seeing how the registers themself got reshuffled.

gicking commented 6 years ago

Sorry, but I don't quite understand. From the reference manuals for STM8L (RM RM0031) and STM8S / STM8A (RM0016) it looks like the sequence is very different, not reverse...?

Here's my understanding:

PCKEN1 (Bit order is MSB->LSB): STM8L: DAC BEEP USART1 SPI1 I2C1 TIM4 TIM3 TIM2 STM8S: TIM1 TIM3 TIM2/TIM5 TIM4/TIM6 UART1/2/3/4 UART1/2/3/4 SPI I2C

PCKEN2: STM8L: BROM res COMPx DMA1 LCD RTC TIM1 ADC1 STM8S: CAN res res res ADC AWU res res

PCKEN2: STM8L: res res CSS/LSE USART3 USART2 SPI2 TIM5 AES STM8S: doesn't exist

blkhawk commented 6 years ago

Well I had seen a few similar registers before that had only "reserved" bits in places the stm8l had. Since PCKEN1 ended with TIMx and the STM8L152 docs had it start with TIMx I chalked up the differences to "hardware differences in peripherals" and assumed the order would be similar. I mean why wouldn't the clock enmable register start with Timers? :)

gicking commented 6 years ago

Just received this via SDCC mailing list -> seems like in the future STM8 headers will be part of SDCC -> mine are obsolete

Am 08.01.2018 um 19:58 schrieb Eric Neblock:

Hey everyone, I was wondering if there was a "missing" header for the stm8.

From the wiki, I found this site:

http://www.colecovision.eu/stm8/STM8SVLDISCOVERY%20LED.shtml

and in the code example, it has things that we'd expect to be in a header file.

So I don't know if I'm not calling things correctly or if this needs to go to the devel list or something else.

Let me know and thanks for your time!

Regards, Eric

Such header files exist as part of ST's STM8 SPL, but due to the unclear license situation the headers will not be included in SDCC before 3.7.0.

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