主题中讨论的其他器件:HALCOGEN
我正在尝试设置 SCI3以便能够接收数据包(等待0x0A)、但我仅触发一个 sciNotification。
我阅读了论坛上其他线程的相关信息、并遵循了建议、但无法使我的代码正常运行。
有人能帮忙吗?
使用 HALCoGen、我已经完成了以下设置:
- 启用的 SCI3驱动器
- 启用 VIM 通道64:SCI3高电平
- SCI3全局:
- TX 中断
- RX 中断
- SCI3数据格式
- 波特率115200
- 1个停止位
- 8个数据位
- 无奇偶校验使能
- 无偶校验
- SCI3端口
- TX、RX 引脚处于功能模式
我的代码如下:
#包含
#include "HL_sys_common.h"
#include "HL_sys_core.h"
#include "HL_sci.h"
uint8 rx_idx;
uint8 rx_buf[32 ];
uint8 tx_buf[ 32 ];
int main (空)
{
UINT8通道;
memset (&rx_buf,0x00,sizeof (rx_buf);
Rx_idx = 0;
memset (&TX_buf、0xAA、sizeof (TX_buf)- 1);
tx_buf[ sizeof (tx_buf)- 1 ]= 0x0A;
sciInit();
_enable_interrupt_();
sciEnableNotification (sciREG3、SCI_RX_INT);
sciEnableLoopback ( sciREG3, Digital_Lbk );
sciReceive ( sciREG3, 1,( uint8 *)&ch );
sciSend ( sciREG3, 32,( uint8 *)&TX_buf[ 0 ]);
while (1);
返回0;
}
void sciNotification ( scibas_t *sci, uint32标志)
{
UINT8通道;
sciReceive ( sci, 1,( uint8 *)&ch );
如果( Ch == 0x0A )
{
Rx_idx = 0;
}
否则
{
/*将字符存储在相应的 SCI Rx 缓冲器和后增量数组索引中*/
rx_buf[ rx_idx ]= ch;
rx_idx++;
}
}
我已将 HALCoGen 项目: