|
BUG的现象
在hercules的设计中,想试下对SCI的RXD,TXD作为GPIO控制输出0,1,可始终都实现不了
BUG处理发现HALCoGen产[size=1.17em]生的代码中初始化SCI中,居然配置的位错了!经TI的FAE确认后,确实是[size=1.17em]HALCoGen 中的BUG!
有时调试硬件或软件时,感觉自己处理的都是没有问题的时候,还是要冷静冷静,再从更深一层,或从更底层从新审核!
软件环境 :HALCoGen 03.06.00
硬件环境 :TMDX570LS20SUSB
功能开启sci1,sci2
在sciInit函数中
void sciInit(void)
{
/* USER CODE BEGIN (2) */
/* USER CODE END */
/** @b initialize @b SCI1 */
/** - bring SCI1 out of reset */
sciREG1->GCR0 = 1U;
/** - Disable all interrupts */
sciREG1->CLRINT = 0xFFFFFFFFU;
sciREG1->CLRINTLVL = 0xFFFFFFFFU;
/** - global control 1 */
sciREG1->GCR1 = (1U << 25U) /* enable transmit */
| (1U << 24U) /* enable receive */
| (1U << 5U) /* internal clock (device has no clock pin) */
| ((2U-1U) << 4U) /* number of stop bits */
| (0U << 3U) /* even parity, otherwise odd */
| (0U << 2U) /* enable parity */
| (1U << 1U); /* asynchronous timing mode */
/** - set baudrate */
sciREG1->BRS = 650U; /* baudrate */
/** - transmission length */
sciREG1->FORMAT = 8U - 1U; /* length */
/** - set SCI1 pins functional mode */
sciREG1->FUN = (1U << 2U) /* tx pin */
| (1U << 1U) /* rx pin */
| (0U); /* clk pin */
/** - set SCI1 pins default output value */
sciREG1->DOUT = (0U << 2U) /* tx pin */
| (0U << 1U) /* rx pin */
| (0U); /* clk pin */
/** - set SCI1 pins output direction */
sciREG1->DIR = (0U << 2U) /* tx pin */
| (0U << 1U) /* rx pin */
| (0U); /* clk pin */
/** - set SCI1 pins open drain enable */
sciREG1->ODR = (0U << 2U) /* tx pin */
| (0U << 1U) /* rx pin */
| (0U); /* clk pin */
/** - set SCI1 pins pullup/pulldown enable */
sciREG1->PD = (0U << 2U) /* tx pin */
| (0U << 1U) /* rx pin */
| (0U); /* clk pin */
/** - set SCI1 pins pullup/pulldown select */
sciREG1->PSL = (1U << 2U) /* tx pin */
| (1U << 1U) /* rx pin */
| (1U); /* clk pin */
/** - set interrupt level */
sciREG1->SETINTLVL = (0U << 26U) /* Framing error */
| (0U << 25U) /* Overrun error */
| (0U << 24U) /* Parity error */
| (0U << 9U) /* Receive */
| (0U << 8U) /* Transmit */
| (0U << 1U) /* Wakeup */
| (0U); /* Break detect */
/** - set interrupt enable */
sciREG1->SETINT = (0U << 26U) /* Framing error */
| (0U << 25U) /* Overrun error */
| (0U << 24U) /* Parity error */
| (1U << 9U) /* Receive */
| (0U << 1U) /* Wakeup */
| (0U); /* Break detect */
/** - initialize global transfer variables */
g_sciTransfer_t[0U].mode = 0U << 8U;
g_sciTransfer_t[0U].length = 0U;
/** - Finaly start SCI1 */
sciREG1->GCR1 |= (1U << 7U);
/** @b initialize @b SCI2 */
/** - bring SCI2 out of reset */
sciREG2->GCR0 = 1U;
/** - Disable all interrupts */
sciREG2->CLRINT = 0xFFFFFFFFU;
sciREG2->CLRINTLVL = 0xFFFFFFFFU;
/** - global control 1 */
sciREG2->GCR1 = (1U << 25U) /* enable transmit */
| (1U << 24U) /* enable receive */
| (1U << 5U) /* internal clock (device has no clock pin) */
| ((2U-1U) << 4U) /* number of stop bits */
| (0U << 3U) /* even parity, otherwise odd */
| (0U << 2U) /* enable parity */
| (1U << 1U); /* asynchronous timing mode */
/** - set baudrate */
sciREG2->BRS = 650U; /* baudrate */
/** - transmission length */
sciREG2->FORMAT = 8U - 1U; /* length */
/** - set SCI2 pins functional mode */
sciREG2->FUN = (1U << 2U) /* tx pin */
| (1U << 1U) /* rx pin */
| (0U); /* clk pin */
/** - set SCI2 pins default output value */
sciREG2->DOUT = (0U << 2U) /* tx pin */
| (0U << 1U) /* rx pin */
| (0U); /* clk pin */
/** - set SCI2 pins output direction */
sciREG2->DIR = (0U << 2U) /* tx pin */
| (0U << 1U) /* rx pin */
| (0U); /* clk pin */
/** - set SCI2 pins open drain enable */
sciREG2->ODR = (0U << 2U) /* tx pin */
| (0U << 1U) /* rx pin */
| (0U); /* clk pin */
/** - set SCI2 pins pullup/pulldown enable */
sciREG2->PD = (0U << 2U) /* tx pin */
| (0U << 1U) /* rx pin */
| (0U); /* clk pin */
/** - set SCI2 pins pullup/pulldown select */
sciREG2->PSL = (1U << 2U) /* tx pin */
| (1U << 1U) /* rx pin */
| (1U); /* clk pin */
/** - set interrupt level */
sciREG2->SETINTLVL = (0U << 26U) /* Framing error */
| (0U << 25U) /* Overrun error */
| (0U << 24U) /* Parity error */
| (0U << 9U) /* Receive */
| (0U << 8U) /* Transmit */
| (0U << 1U) /* Wakeup */
| (0U); /* Break detect */
/** - set interrupt enable */
sciREG2->SETINT = (0U << 26U) /* Framing error */
| (0U << 25U) /* Overrun error */
| (0U << 24U) /* Parity error */
| (1U << 9U) /* Receive */
| (0U << 1U) /* Wakeup */
| (0U); /* Break detect */
/** - initialize global transfer variables */
g_sciTransfer_t[0U].mode = 0U << 8U;
g_sciTransfer_t[0U].length = 0U;
这里自动生成为"0U",应该是"1U"
/** - Finaly start SCI2 */
sciREG2->GCR1 |= (1U << 7U);
/* USER CODE BEGIN (3) */
/* USER CODE END */
}
|
|