Skip to content

Commit

Permalink
fixes #57 support UART1 Half-Duplex, fixes #58 support STM8S001J3M3
Browse files Browse the repository at this point in the history
  • Loading branch information
TG9541 committed Sep 12, 2017
1 parent d9c4bd7 commit 7c13d7e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions forth.asm
Expand Up @@ -441,16 +441,19 @@ COLD:
.ifne HAS_RXUART+HAS_TXUART
; Init RS232 communication port
; STM8S[01]003F3 init UART
LDW X,#0x6803 ; 9600 baud
LDW UART_BRR1,X ;
LDW X,#0x6803 ; 9600 baud
LDW UART_BRR1,X
.ifne HAS_RXUART*HAS_TXUART
MOV UART_CR2,#0x0C ; Use UART1 full duplex
MOV UART_CR2,#0x0C ; Use UART1 full duplex
.ifne HALF_DUPLEX
MOV UART1_CR5,#0x08 ; UART1 Half-Duplex
.endif
.else
.ifne HAS_TXUART
MOV UART_CR2,#0x08 ; UART1 enable tx
MOV UART_CR2,#0x08 ; UART1 enable tx
.endif
.ifne HAS_RXUART
MOV UART_CR2,#0x04 ; UART1 enable rx
MOV UART_CR2,#0x04 ; UART1 enable rx
.endif
.endif
.endif
Expand Down Expand Up @@ -641,10 +644,9 @@ TXSTOR:
INCW X

.ifne HALF_DUPLEX * (1-HAS_TXSIM)
; TODO: this is most likely obsolete
; HALF_DUPLEX with normal UART (e.g. wired-or Rx and Tx)
BRES UART_CR2,#2 ; disable rx
1$: BTJF UART_SR,#7,1$ ; loop until tdre
BRES UART_CR2,#2 ; disable rx
LD UART_DR,A ; send A
2$: BTJF UART_SR,#6,2$ ; loop until tc
BSET UART_CR2,#2 ; enable rx
Expand Down
2 changes: 1 addition & 1 deletion stm8device.inc
Expand Up @@ -11,7 +11,7 @@
PORTG = PG_ODR
PORTH = PH_ODR
PORTI = PI_ODR
PORTX = 0
PORTX = 0

ODR = 0
IDR = 1
Expand Down

0 comments on commit 7c13d7e

Please sign in to comment.