From: Philipp K. K. <pk...@sp...> - 2017-10-12 13:37:10
|
Am 12.10.2017 um 12:40 schrieb Timo Fuckner: > Hello everyone, > > I am currently having trouble writing the controlling registers for the ADC on STM8L152C6 (the discovery board [1]). Reading and writing the IO data and control registers works fine, but I can't change anything in the ADC registers as it seems, as they never change their RESET state. When reading them directly after setting them and directing the output to uart, there is no change. I'm not exactly sure if this is compiler or linker related, but to the best of my knowledge I did everything according to the handbook [2]. > > The affected registers are: > ADC1_CR1 > ADC1_CR2 > ADC1_CR3 > ADC1_SQR1 > ADC1_SQR2 > ADC1_SQR3 > ADC1_SQR4 > > You can find my sourcecode here [3], SDCC version is 3.6, Win7. > The sdcc command is "sdcc -mstm8 --std-c99 usart.c". > For flashing I am using ST Visual Programmer 3.4.0. > > I hope this is actually a bug in the compiler or linker and not a user error, so I won't waste your time. > > Regards, > Timo Well, this code looks like you don't set ADON (lowest bit of ADC1_CR1) to 1, while most ADC registers cannot be writtenwhile ADON is 0. Philipp |