initializing UART2 of STM8s105 in asm coding
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2015-03-16 5:40 AM
Posted on March 16, 2015 at 13:40
hello,
here under my asm code for initializing UART2 of STM8s 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 = 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
thanks for your help.
Joël
This discussion is locked. Please start a new topic to ask your question.
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2015-03-16 3:02 PM
Posted on March 16, 2015 at 23:02
I have found my problem . I had remove UART clock . grrrr !!!
mov CLK_PCKENR1 , #%11110000 ;supprime le clock sur les oscillateurs pour les UART , SPI et I2C /!\ replace by mov CLK_PCKENR1 , #%11111100 ;supprime le clock sur les oscillateurs pour lesUART
, SPI et I2C /!\