AnsweredAssumed Answered

initializing UART2 of STM8s105 in asm coding

Question asked by joel.le_cam on Mar 16, 2015
Latest reply on Mar 16, 2015 by joel.le_cam

hello,

here under my asm code for initializing UART2  of STM8s105. I use STVD IDE with stm8s discovery.

when I put a break point at the end of the init, all the UART2 peripherals remains at  0x0000.  I don't understand because I have init many others peripherals GPIO, Timer ...

;Uart variables
M    EQU 4     ; 8 ou 9 bit CR1
stop EQU 5     ; 1 stop bit CR3
bits EQU 4     ; 2 stop bit CR3
 
TC  EQU 6     ; TC flag fin d'envoi
TXE EQU 7     ; TXE flag write data
 
CKEN            EQU 3 ; clock mode in CR3
REN             EQU 2 ; REN bit recept mode in CR2
TEN             EQU 3     ; TEN bit transmit mode in CR2
 
 
 
; init UART2
reset_uart_register
 
mov UART2_CR1,#0
        mov UART2_CR2,#0
           mov UART2_CR3,#0
 
init_UART2                     ; 2400 bauds =   16.000.000 / 2200 = 6666d = 1A0B hex
        bres UART2_CR1  , #M            ; word lenth 8 bits
           bset UART2_CR3  , #stop            ; 2 bits stops
        bset UART2_CR3  , #bits    ; 2 bits stops
        mov UART2_BRR1 , #$A0    ; UART2 Baud Rate Register 1
        mov UART2_BRR2 , #$1B    ; UART2 Baud Rate Register 2
 
 
        ld A , UART2_CR3
"break point" nop
 
rim  ;reset the cpu interupt mask    
; end of initialisation of all peripherals
 
 


hereunder a screenshot of the STVD IDE at the break point

 https://my.st.com/tmtrack/tmtrack.dll?AttachmentPage&AttachmentID=1977/STVD-view-Uart2-initialisation.pdf

thanks for your help.

Joël

Outcomes