MTK 串口无波形
时间:10-02
整理:3721RD
点击:
平台:MT2503D
我是直接在 MMI_task 中注入的测试代码,测试硬件串口上没有波形,是不是串口需要硬件配置IO口的?
问题解决,是IO口的模式没配,可以有drgen来配也可以用IO的序号配。下列代码可以用来学习串口配置和通讯,没有用任务扑捉事件!
catcher 抓到的log 如下,写入的返回值是9
测试代码如下:
void sl_test_init(void) {
#if 1 /* TEST SERIAL */
{
DCL_STATUS status;
{
handle = DclSerialPort_Open(UART_port1, 0);
__sl_trace("Handle :%d", handle);
}
//power on and open
{
UART_CTRL_POWERON_T power_ctl;
power_ctl.bFlag_Poweron = true;
DclSerialPort_Control(handle, UART_CMD_POWER_ON, (DCL_CTRL_DATA_T*)&power_ctl);
__sl_trace("poweron ok");
}
//open
{
UART_CTRL_OPEN_T open_ctl;
open_ctl.u4OwenrId = MOD_MMI;
status = DclSerialPort_Control(handle, SIO_CMD_OPEN, (DCL_CTRL_DATA_T*)&open_ctl);
if (STATUS_OK != status) {
__sl_trace("open port failed:%d", status);
}
}
//config
{
UART_CTRL_DCB_T config;
config.u4OwenrId = MOD_MMI;
config.rUARTConfig.u4Baud = UART_BAUD_115200;
config.rUARTConfig.u1DataBits = LEN_8;
config.rUARTConfig.u1StopBits = SB_1;
config.rUARTConfig.u1Parity = PA_NONE;
config.rUARTConfig.u1FlowControl = FC_NONE;
config.rUARTConfig.ucXonChar = 0x11;
config.rUARTConfig.ucXoffChar = 0x13;
config.rUARTConfig.fgDSRCheck = (DCL_BOOLEAN)KAL_FALSE;
status = DclSerialPort_Control(handle, SIO_CMD_SET_DCB_CONFIG, (DCL_CTRL_DATA_T*)&config);
if (STATUS_OK != status) {
__sl_trace("config port failed:%d", status);
}
}
//check owner id
{
UART_CTRL_OWNER_T iddata;
DclSerialPort_Control(handle, SIO_CMD_GET_OWNER_ID, (DCL_CTRL_DATA_T*)&iddata);
__sl_trace("owner ID:%d,MMI_ID:%d", (module_type)(iddata.u4OwenrId),MOD_MMI);
}
//write the first package
{
UART_CTRL_PUT_BYTES_T wdata;
wdata.u4OwenrId = MOD_MMI;
wdata.u2Length = 9;
wdata.puBuffaddr = "Hello world";
DclSerialPort_Control(handle, SIO_CMD_PUT_BYTES, (DCL_CTRL_DATA_T*)&wdata);
__sl_trace("Write :%d", wdata.u2RetSize);
}
StartTimer(SLUAN_TIMER_ID_1, 5000, sl_test_timer_cb);
}
#endif
}
路过,看看
頂一下