不知爲何,STM32的中、小容量啓動文件中沒有發現UART4,UART5的中斷處理函數,也就是在HD如下的版本中是沒有UART四、UART5中斷的嘍?但查了下,中等容量的STM32F103RCT6是有UART四、UART5的,而且支持部份中斷,如下摘自庫函數(@version V3.5.0)說明:web
/**
* @brief Enables or disables the specified USART interrupts.
* @param USARTx: Select the USART or the UART peripheral.
* This parameter can be one of the following values:
* USART1, USART2, USART3, UART4 or UART5.
* @param USART_IT: specifies the USART interrupt sources to be enabled or disabled.
* This parameter can be one of the following values:
* @arg USART_IT_CTS: CTS change interrupt (not available for UART4 and UART5)
* @arg USART_IT_LBD: LIN Break detection interrupt
* @arg USART_IT_TXE: Tansmit Data Register empty interrupt
* @arg USART_IT_TC: Transmission complete interrupt
* @arg USART_IT_RXNE: Receive Data register not empty interrupt
* @arg USART_IT_IDLE: Idle line detection interrupt
* @arg USART_IT_PE: Parity Error interrupt
* @arg USART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
* @param NewState: new state of the specified USARTx interrupts.
* This parameter can be: ENABLE or DISABLE.
* @retval None
*/函數
很明顯,UART四、UART5是具有產生中斷的能力的。那麼爲什麼沒有相應的中斷呢?此點暫不得而知。解決辦法也是有的,最簡單採用startup_stm32f10x_hd.s便可,不過涉及到內存分配,此處不予討論。也可在對就容量的啓動文件中添加代碼:spa
IMPORT UART4_IRQHandler
IMPORT UART5_IRQHandler.net
DCD UART4_IRQHandler
DCD UART5_IRQHandlerorm
自此算是基本解決了。ip
----------------------------------------------------------------------------------------------------------------------內存
感謝@mcloud ,此處有一個重大的問題我一直沒有注意到!那就是對於STM32啓動文件的理解。如下貼上STM32啓動文件的相關內容:ci
小容量產品是指閃存存儲器容量在16K至32K字節之間的STM32F101xx、STM32F102xx和STM32F103xx微控制器。文檔
中容量產品是指閃存存儲器容量在64K至128K字節之間的STM32F101xx、STM32F102xx和STM32F103xx微控制器。get
大容量產品是指閃存存儲器容量在256K至512K字節之間的STM32F101xx和STM32F103xx微控制器。
互聯型產品是指STM32F105xx和STM32F107xx微控制器。
- startup_stm32f10x_ld_vl.s: for STM32 Low density Value line devices
- startup_stm32f10x_ld.s: for STM32 Low density devices
- startup_stm32f10x_md_vl.s: for STM32 Medium density Value line devices
- startup_stm32f10x_md.s: for STM32 Medium density devices
- startup_stm32f10x_hd.s: for STM32 High density devices
- startup_stm32f10x_xl.s: for STM32 XL density devices
- startup_stm32f10x_cl.s: for STM32 Connectivity line devices
cl:互聯型產品,stm32f105/107系列
vl:超值型產品,stm32f100系列
xl:超高密度產品,stm32f101/103系列
ld:低密度產品,FLASH小於64K
md:中等密度產品,FLASH=64 or 128
hd:高密度產品,FLASH大於128
● Low-density devices: STM32F101xx, STM32F102xx and STM32F103xx
microcontrollers where the Flash memory density ranges between 16 and 32 Kbytes.
● Medium-density devices: STM32F101xx, STM32F102xx and STM32F103xx
microcontrollers where the Flash memory density ranges between 64 and 128 Kbytes.
● High-density devices: STM32F101xx and STM32F103xx microcontrollers where the
Flash memory density ranges between 256 and 512 Kbytes.
● XL-density devices: STM32F101xx and STM32F103xx microcontrollers where the
Flash memory density ranges between 512 and 1024 Kbytes.
● Medium-density Low-Power devices: STM32L15xx microcontrollers where the Flash
memory density ranges between 64 and 128 Kbytes.
● Low Power Medium-density Plus devices:STM32L15xx and STM32L162xx
microcontrollers where the Flash memory density is 256 Kbytes.
● Low Power High-density devices: STM32L15xx and STM32L162xx microcontrollers
where the Flash memory density is 384 Kbytes.
那麼問題來了,我之因此會有如題的疑惑,乃是由於用着STM32F103RCT6這款芯片,卻用的是startup_stm32f10x_md.s的啓動文件,那天然是沒UART四、UART5的。而STM32F103RCT6實則是256K內存,屬於 hd:高密度產品,FLASH大於128 。難怪在看芯片文檔時,該芯片是有UART四、UART5的。