21ic问答首页 - 小华单片机HC32F460的跑官方例程时会发送不成功
小华单片机HC32F460的跑官方例程时会发送不成功
luckyren2023-03-02
目前在调试HC32F460时会卡在如下代码:在while (CAN_GetStatus(CAN_UNIT, CAN_FLAG_STB_TX) == RESET) { },哪位大佬可以指点一下吗?static void CanTx(void)
{
uint8_t i;
static uint8_t u8Data;
for (i = 0U; i < CAN_TX_DATA_SIZE; i++) {
m_stcTx1.au8Data[i] = u8Data++;
m_stcTx2.au8Data[i] = u8Data++;
m_stcTx3.au8Data[i] = u8Data++;
}
/* Frame with CAN_ID1 */
m_stcTx1.u32Ctrl = 0x0UL;
m_stcTx1.u32ID = CAN_TX_ID1;
m_stcTx1.IDE = CAN_TX_ID1_IDE;
m_stcTx1.DLC = CAN_TX_DLC;
(void)CAN_FillTxFrame(CAN_UNIT, CAN_TX_BUF_PTB, &m_stcTx1);
/* Start PTB TX */
CAN_StartTx(CAN_UNIT, CAN_TX_REQ_PTB);
/* Check transmission end. */
while (CAN_GetStatus(CAN_UNIT, CAN_FLAG_PTB_TX) == RESET) { }
CAN_ClearStatus(CAN_UNIT, CAN_FLAG_PTB_TX);
/* Frame with CAN_ID2 */
m_stcTx2.u32Ctrl = 0x0UL;
m_stcTx2.u32ID = CAN_TX_ID2;
m_stcTx2.IDE = CAN_TX_ID2_IDE;
m_stcTx2.DLC = CAN_TX_DLC;
(void)CAN_FillTxFrame(CAN_UNIT, CAN_TX_BUF_STB, &m_stcTx2);
/* Frame with CAN_ID3 */
m_stcTx3.u32Ctrl = 0x0UL;
m_stcTx3.u32ID = CAN_TX_ID3;
m_stcTx3.IDE = CAN_TX_ID3_IDE;
m_stcTx3.DLC = CAN_TX_DLC;
(void)CAN_FillTxFrame(CAN_UNIT, CAN_TX_BUF_STB, &m_stcTx3);
/* Start STB TX */
CAN_StartTx(CAN_UNIT, CAN_TX_REQ_STB_ALL);
/* Check transmission end. */
while (CAN_GetStatus(CAN_UNIT, CAN_FLAG_STB_TX) == RESET) { }
CAN_ClearStatus(CAN_UNIT, CAN_FLAG_STB_TX);
}
{
uint8_t i;
static uint8_t u8Data;
for (i = 0U; i < CAN_TX_DATA_SIZE; i++) {
m_stcTx1.au8Data[i] = u8Data++;
m_stcTx2.au8Data[i] = u8Data++;
m_stcTx3.au8Data[i] = u8Data++;
}
/* Frame with CAN_ID1 */
m_stcTx1.u32Ctrl = 0x0UL;
m_stcTx1.u32ID = CAN_TX_ID1;
m_stcTx1.IDE = CAN_TX_ID1_IDE;
m_stcTx1.DLC = CAN_TX_DLC;
(void)CAN_FillTxFrame(CAN_UNIT, CAN_TX_BUF_PTB, &m_stcTx1);
/* Start PTB TX */
CAN_StartTx(CAN_UNIT, CAN_TX_REQ_PTB);
/* Check transmission end. */
while (CAN_GetStatus(CAN_UNIT, CAN_FLAG_PTB_TX) == RESET) { }
CAN_ClearStatus(CAN_UNIT, CAN_FLAG_PTB_TX);
/* Frame with CAN_ID2 */
m_stcTx2.u32Ctrl = 0x0UL;
m_stcTx2.u32ID = CAN_TX_ID2;
m_stcTx2.IDE = CAN_TX_ID2_IDE;
m_stcTx2.DLC = CAN_TX_DLC;
(void)CAN_FillTxFrame(CAN_UNIT, CAN_TX_BUF_STB, &m_stcTx2);
/* Frame with CAN_ID3 */
m_stcTx3.u32Ctrl = 0x0UL;
m_stcTx3.u32ID = CAN_TX_ID3;
m_stcTx3.IDE = CAN_TX_ID3_IDE;
m_stcTx3.DLC = CAN_TX_DLC;
(void)CAN_FillTxFrame(CAN_UNIT, CAN_TX_BUF_STB, &m_stcTx3);
/* Start STB TX */
CAN_StartTx(CAN_UNIT, CAN_TX_REQ_STB_ALL);
/* Check transmission end. */
while (CAN_GetStatus(CAN_UNIT, CAN_FLAG_STB_TX) == RESET) { }
CAN_ClearStatus(CAN_UNIT, CAN_FLAG_STB_TX);
}
赞0
评论
2023-12-08
赞0
评论
2023-12-07
赞0
评论
2023-12-07
赞0
评论
2023-12-07
赞0
评论
2023-12-04
赞0
评论
2023-03-03
您需要登录后才可以回复 登录 | 注册