-
Notifications
You must be signed in to change notification settings - Fork 2
/
FISH_STM32F4_UART3_INIT.s
40 lines (38 loc) · 1.3 KB
/
FISH_STM32F4_UART3_INIT.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// FISH_STM32F4_UART3_INIT.s
// STM32F4 UART3_INIT UART3_INIT: ( -- )
// If setting BAUD MYBAUD MUST BE USED FIRST
// THIS IS TO PRESERVE YOUR BAUD DURING HARD FAULT RESET
// Use DEFAULT_BAUD UNLESS DBAUD IS ZERO, THEN USE UBAUD VALUE
// WHEN DBAUD IS NOT ZERO USE DEFAULT_BAUD // pwrup
// WHEN DBAUD IS ZERO USE UBAUD // RESET
SECTION .text : CONST (2)
UART3_INIT_NFA:
DC8 0x8A
DC8 'UART3_INI'
DC8 'T'+0x80
ALIGNROM 2,0xFFFFFFFF
DC32 WC_NUMBERS_NFA
UART3_INIT:
DC32 DOCOL
// GET DEFAULT OR USER SET BAUD (MYBAUD)
DC32 LIT, DBAUD, AT, ZEQU
DC32 ZBRAN
DC32 BAUDDEFAULT-. // IF DBAUD not ZERO SET DEFAULT_BAUD
DC32 LIT, UBAUD, AT // IARBUG , TOR
DC32 TOR // ELSE USE UBAUD
DC32 BRAN
DC32 BAUD1-. // SET UBAUD TO ZERO TO PRESERVE UBAUD
BAUDDEFAULT: // ELSE
DC32 LIT, DEFAULT_BAUD // IARBUG , TOR
DC32 TOR // SET
BAUD1:
// BAUD IS ON R STACK
// USE IT TO CALCULATE UART3_BRR VALUE
// HAVE TO USE PCLK1 WHICH IS EQUATED IN SOCINIT
// PCLK1 = 42000000
DC32 LIT, PCLK1 // 280DE80h @ 168MHZ SYSCLK
DC32 RFROM // 2580h = 9600 DEFAULT_BAUD
DC32 SLASH
DC32 LIT, USART3_BRR
DC32 STORE // 1117h FOR 9600/42MHZ PCLK1
DC32 SEMIS