求大老解惑,我想把{0x7e,0x00,0x01,0x02,0x03}这个数组通过串口中断发送出去,首字节0x7e直接通过查询法输出,其他字节通过中断方法发出去。程序代码如下,但是在上位机中只能显示0x7e,其他数据没传过来,不知道是什么原因。本人菜鸟一枚,求大腿帮小弟一把,万分感谢
extern uint8_t TxBuffer1[5] = {0x7e,0x00,0x01,0x02,0x03};//定义一个传送buffer
extern uint8_t RxBuffer1[];
extern uint8_t Txcounter = 0;//定义传送长度
void main(void)
{
/* CLK configuration -----------------------------------------*/
CLK_Config();
/* UART configuration -----------------------------------------*/
UART1_Config();
UART1_Send_Data(TxBuffer1[0]);
while (1)
{
}
}
void UART1_Config(void)
{
/* Deinitializes the UART1 and UART3 peripheral */
UART1_DeInit();
//UART3_DeInit();
/* UART1 and UART3 configuration -------------------------------------------------*/
/* UART1 and UART3 configured as follow:
- BaudRate = 9600 baud
- Word Length = 8 Bits
- One Stop Bit
- No parity
- Receive and transmit enabled
- UART1 Clock disabled
*/
/* Configure the UART1 */
UART1_Init((uint32_t)9600, UART1_WORDLENGTH_8D, UART1_STOPBITS_1, UART1_PARITY_NO,
UART1_SYNCMODE_CLOCK_DISABLE, UART1_MODE_TXRX_ENABLE);
/* Enable UART1 Transmit interrupt*/
UART1_ITConfig(UART1_IT_TXE, ENABLE);
/* Enable general interrupts */
enableInterrupts();
}
INTERRUPT_HANDLER(UART1_TX_IRQHandler, 17)
{
if(UART1_GetITStatus(UART1_IT_TXE) != RESET)
UART1_ClearITPendingBit(UART1_IT_TXE);
UART1_SendData8(TxBuffer1[Txcounter]);
Txcounter++;
if(Txcounter == 5)
{
UART1_ITConfig(UART1_IT_TXE, DISABLE);
}
}
|