菜鸟一枚,我目前正在使用 ti的TMS570LS0432 开发板,目前最大的问题就是SCI串口收发中断函数linHighLevelInterrupt进不去,跑官方的串口发送例程可以正常发送到串口调试工具中,但是改用中断的话收发都不行。查阅了各类资料也没办法解决,代码如下,工程文件放在附件里了,原谅我在这里做一个伸手党,希望有大佬帮忙看一看,我哪里出了问题,毕设急用,已经困扰了我两天了,求大佬相助,不胜感激。
sys_main.c (使能了两个中断,但如果只使能收或发中断也同样无法触发)
- /* USER CODE BEGIN (0) */
- /* USER CODE END */
- /* Include Files */
- #include "sys_common.h"
- /* USER CODE BEGIN (1) */
- #include "sci.h"
- #define TSIZE1 10
- uint8 TEXT1[TSIZE1]= {'H','E','R','C','U','L','E','S',' ',' '};
- #define TSIZE2 18
- uint8 TEXT2[TSIZE2]= {'M','I','C','R','O','C','O','N','T','R','O','L','L','E','R','S',' ',' '};
- #define TSIZE3 19
- uint8 TEXT3[TSIZE3]= {'T','E','X','A','S',' ','I','N','S','T','R','U','M','E','N','T','S','n','r'};
- /* USER CODE END */
- /** @fn void main(void)
- * [url=home.php?mod=space&uid=2666770]@Brief[/url] Application main function
- * [url=home.php?mod=space&uid=1902110]@NOTE[/url] This function is empty by default.
- *
- * This function is called after startup.
- * The user can use this function to implement the application.
- */
- /* USER CODE BEGIN (2) */
- /* USER CODE END */
- int main(void)
- {
- /* USER CODE BEGIN (3) */
- sciInit();
- _enable_IRQ();
- sciEnableNotification(scilinREG,SCI_TX_INT);
- sciEnableNotification(scilinREG,SCI_RX_INT);
- while(1)
- {
- sciSendByte(scilinREG,TEXT1[0]);
- }
- /* USER CODE END */
- }
- /* USER CODE BEGIN (4) */
- /* USER CODE END */
复制代码
sci.c sciInit()函数
- void sciInit(void)
- {
- /* USER CODE BEGIN (2) */
- /* USER CODE END */
- /** [url=home.php?mod=space&uid=19335]@B[/url] initialize @b SCILIN */
- /** - bring SCI out of reset */
- scilinREG->GCR0 = 0U;
- scilinREG->GCR0 = 1U;
- /** - Disable all interrupts */
- scilinREG->CLEARINT = 0xFFFFFFFFU;
- scilinREG->CLEARINTLVL = 0xFFFFFFFFU;
- /** - global control 1 */
- scilinREG->GCR1 = (uint32)((uint32)1U << 25U) /* enable transmit */
- | (uint32)((uint32)1U << 24U) /* enable receive */
- | (uint32)((uint32)1U << 5U) /* internal clock (device has no clock pin) */
- | (uint32)((uint32)(2U-1U) << 4U) /* number of stop bits */
- | (uint32)((uint32)0U << 3U) /* even parity, otherwise odd */
- | (uint32)((uint32)0U << 2U) /* enable parity */
- | (uint32)((uint32)1U << 1U); /* asynchronous timing mode */
-
- /** - set baudrate */
- scilinREG->BRS = 520U; /* baudrate */
- /** - transmission length */
- scilinREG->FORMAT = 8U - 1U; /* length */
- /** - set SCI pins functional mode */
- scilinREG->PIO0 = (uint32)((uint32)1U << 2U) /* tx pin */
- | (uint32)((uint32)1U << 1U); /* rx pin */
- /** - set SCI pins default output value */
- scilinREG->PIO3 = (uint32)((uint32)0U << 2U) /* tx pin */
- | (uint32)((uint32)0U << 1U); /* rx pin */
- /** - set SCI pins output direction */
- scilinREG->PIO1 = (uint32)((uint32)1U << 2U) /* tx pin */
- | (uint32)((uint32)0U << 1U); /* rx pin */
- /** - set SCI pins open drain enable */
- scilinREG->PIO6 = (uint32)((uint32)0U << 2U) /* tx pin */
- | (uint32)((uint32)0U << 1U); /* rx pin */
- /** - set SCI pins pullup/pulldown enable */
- scilinREG->PIO7 = (uint32)((uint32)0U << 2U) /* tx pin */
- | (uint32)((uint32)0U << 1U); /* rx pin */
- /** - set SCI pins pullup/pulldown select */
- scilinREG->PIO8 = (uint32)((uint32)1U << 2U) /* tx pin */
- | (uint32)((uint32)1U << 1U); /* rx pin */
- /** - set interrupt level */
- scilinREG->SETINTLVL = (uint32)((uint32)0U << 26U) /* Framing error */
- | (uint32)((uint32)0U << 25U) /* Overrun error */
- | (uint32)((uint32)0U << 24U) /* Parity error */
- | (uint32)((uint32)1U << 9U) /* Receive */
- | (uint32)((uint32)1U << 8U) /* Transmit */
- | (uint32)((uint32)0U << 1U) /* Wakeup */
- | (uint32)((uint32)0U << 0U); /* Break detect */
- /** - set interrupt enable */
- scilinREG->SETINT = (uint32)((uint32)0U << 26U) /* Framing error */
- | (uint32)((uint32)0U << 25U) /* Overrun error */
- | (uint32)((uint32)0U << 24U) /* Parity error */
- | (uint32)((uint32)1U << 9U) /* Receive */
- | (uint32)((uint32)0U << 1U) /* Wakeup */
- | (uint32)((uint32)0U); /* Break detect */
- /** - initialize global transfer variables */
- g_sciTransfer_t.mode = (uint32)1U << 8U;
- g_sciTransfer_t.tx_length = 0U;
- g_sciTransfer_t.rx_length = 0U;
- /** - Finaly start SCILIN */
- scilinREG->GCR1 |= 0x80U;
- /* USER CODE BEGIN (3) */
- /* USER CODE END */
- }
复制代码
sci.c linHighLevelInterrupt()中断函数(进不去)
- void linHighLevelInterrupt(void)
- {
- uint32 vec = scilinREG->INTVECT0;
- uint8 byte;
- /* USER CODE BEGIN (29) */
- /* USER CODE END */
- switch (vec)
- {
- case 1U:
- sciNotification(scilinREG, (uint32)SCI_WAKE_INT);
- break;
- case 3U:
- sciNotification(scilinREG, (uint32)SCI_PE_INT);
- break;
- case 6U:
- sciNotification(scilinREG, (uint32)SCI_FE_INT);
- break;
- case 7U:
- sciNotification(scilinREG, (uint32)SCI_BREAK_INT);
- break;
- case 9U:
- sciNotification(scilinREG, (uint32)SCI_OE_INT);
- break;
- case 11U:
- /* receive */
- byte = (uint8)(scilinREG->RD & 0x000000FFU);
- if (g_sciTransfer_t.rx_length > 0U)
- {
- *g_sciTransfer_t.rx_data = byte;
- /*SAFETYMCUSW 567 S MR:17.1,17.4 "Pointer increment needed" */
- g_sciTransfer_t.rx_data++;
- g_sciTransfer_t.rx_length--;
- if (g_sciTransfer_t.rx_length == 0U)
- {
- sciNotification(scilinREG, (uint32)SCI_RX_INT);
- }
- }
- break;
- case 12U:
- /* transmit */
- /*SAFETYMCUSW 30 S MR:12.2,12.3 "Used for data count in Transmit/Receive polling and Interrupt mode" */
- --g_sciTransfer_t.tx_length;
- if ((g_sciTransfer_t.tx_length) > 0U)
- {
- uint8 txdata = *g_sciTransfer_t.tx_data;
- scilinREG->TD = (uint32)(txdata);
- /*SAFETYMCUSW 567 S MR:17.1,17.4 "Pointer increment needed" */
- g_sciTransfer_t.tx_data++;
- }
- else
- {
- scilinREG->CLEARINT = SCI_TX_INT;
- sciNotification(scilinREG, (uint32)SCI_TX_INT);
- }
- break;
- default:
- /* phantom interrupt, clear flags and return */
- scilinREG->FLR = ~scilinREG->SETINTLVL & 0x07000303U;
- break;
- }
复制代码
notification.c sciNotification()函数部分(为了测试能不能进去只加了个return,发现进不去)
- #pragma WEAK(sciNotification)
- void sciNotification(sciBASE_t *sci, uint32 flags)
- {
- /* enter user code between the USER CODE BEGIN and USER CODE END. */
- /* USER CODE BEGIN (29) */
- return;
- /* USER CODE END */
- }
复制代码
0
已退回2积分
|
1个回答
|
|
|