File tree 2 files changed +12
-2
lines changed
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ void init_bss(void)
64
64
unsigned int * dst ;
65
65
66
66
dst = & __bss_start ;
67
- while (dst < & __bss_end )
67
+ while (( rt_ubase_t ) dst < ( rt_ubase_t ) & __bss_end )
68
68
{
69
69
* dst ++ = 0 ;
70
70
}
Original file line number Diff line number Diff line change @@ -129,7 +129,17 @@ static void _uart_init(void *uart_base)
129
129
dlh = bdiv >> 12 ;
130
130
dll = (bdiv - (dlh << 12 )) / 16 ;
131
131
dlf = bdiv - (dlh << 12 ) - dll * 16 ;
132
- if (dlh == 0 && dll == 0 )
132
+ // dlh can be 0 only if bdiv < 4096 (since we're shifting right by 12 bits)
133
+ // bdiv = UART_CLK / UART_DEFAULT_BAUDRATE
134
+ // = 50000000 / 115200
135
+ // = 434.027
136
+ // so when dlh is 0,
137
+ // dll = (bdiv - (dlh << 12)) / 16
138
+ // = (434.027 - 0) / 16
139
+ // = 27.626
140
+ // which means dll can not reach 0,
141
+ // so we use 1 as the minimum value for dll
142
+ if ((dlh == 0 ) && (dll < 1 ))
133
143
{
134
144
dll = 1 ;
135
145
dlf = 0 ;
You can’t perform that action at this time.
0 commit comments