Am 12.10.2017 um 14:24 schrieb Timo Fuckner: > Ok so I just removed the unnecessary stuff and created a minimal example: > > https://pastebin.com/QPE14keu > > Writing a 0x01 in ADC1_CR1 results on 0x00 when read out. > > Regards, > Timo
I cna reproduce the issue using curretn SDCC on my STM8L-Discovery with this code: // Source code under CC0 1.0 #include <stdint.h> #include <stdio.h> #define PC_DDR (*(volatile uint8_t *)0x500c) #define PC_CR1 (*(volatile uint8_t *)0x500d) #define EVER (;;) //ADC Registers #define ADC1_CR1 (*(volatile uint8_t *)0x5340) #define ADC1_CR2 (*(volatile uint8_t *)0x5341) #define ADC1_CR3 (*(volatile uint8_t *)0x5342) //Clock #define CLK_DIVR (*(volatile uint8_t *)0x50C0) #define CLK_PCKENR1 (*(volatile uint8_t *)0x50C3) #define CLK_PCKENR2 (*(volatile uint8_t *)0x50C4) //USART #define USART1_SR (*(volatile uint8_t *)0x5230) #define USART1_DR (*(volatile uint8_t *)0x5231) #define USART1_BRR1 (*(volatile uint8_t *)0x5232) #define USART1_BRR2 (*(volatile uint8_t *)0x5233) #define USART1_CR2 (*(volatile uint8_t *)0x5235) #define USART1_CR3 (*(volatile uint8_t *)0x5236) #define USART_CR2_TEN (1 << 3) #define USART_CR3_STOP2 (1 << 5) #define USART_CR3_STOP1 (1 << 4) #define USART_SR_TXE (1 << 7) // we need to provide putchar, as it is controller specific int putchar(int c) { while(!(USART1_SR & USART_SR_TXE)); USART1_DR = c; return(c); } void uart_init(void) { PC_DDR = 0x08; // Put TX line on PC_CR1 = 0x08; USART1_CR2 = USART_CR2_TEN; // Allow TX and RX USART1_CR3 &= ~(USART_CR3_STOP1 | USART_CR3_STOP2); // 1 stop bit USART1_BRR2 = 0x03; USART1_BRR1 = 0x68; // 9600 baud } void main(void) { unsigned long i = 0; CLK_DIVR = 0x00; // Set the frequency to 16 MHz CLK_PCKENR1 |= 0xFF; //(1 << 5) & (1 << 7); // Enable peripherals UART & ADC uart_init(); printf("Restarted...\r\n"); for EVER { ADC1_CR1 = 0x01; printf("ADC1_CR1: %X\r\n", ADC1_CR1); for(i = 0; i < 0xFFFFF; i++); // Sleep } } ------------------------------------------------------------------------------ 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