这样把UTX0IF清零为什么不行?串口不发数据出来
时间:10-02
整理:3721RD
点击:
#include <iocc2530.h>
#include <string.h>
#define TX_SIZE 20
#define TX_STRING "Hello Zigbee "
char TxData[TX_SIZE];
void init_clock (void);
void init_uart (void);
void delay (unsigned mse);
void uart_send_string (char *data, int len);
void main (void)
{
init_clock ();
init_uart ();
memset (TxData, 0, TX_SIZE);
memcpy (TxData, TX_STRING, sizeof(TX_STRING));
while (1)
{
uart_send_string (TxData, sizeof(TX_STRING));
delay (1000);
}
}
void init_clock (void)
{
CLKCONCMD &= ~0x40;
while (CLKCONCMD & 0x40);
CLKCONCMD &= ~0x47;
}
void init_uart (void)
{
PERCFG = 0x00;
P0SEL = 0x0c;
P2DIR &= ~0xc0;
U0CSR |= 0x80;
U0GCR |= 11;
U0BAUD |= 216;
UTX0IF = 0;
IEN2 |= 0x04;
IEN0 |= 0x80;
}
void delay (unsigned mse)
{
unsigned int i,j;
for (i = 0; i < mse; i++)
for (j = 0; j < 1070; j++);
}
void uart_send_string (char *data, int len)
{
unsigned int i;
for (i = 0; i < len; i++)
{
U0DBUF = *data++;
while (UTX0IF == 0);
//UTX0IF = 0;
}
}
#pragma vector = UTX0_VECTOR
__interrupt void UART0_ISR (void)
{
UTX0IF = 0;
}
#include <string.h>
#define TX_SIZE 20
#define TX_STRING "Hello Zigbee "
char TxData[TX_SIZE];
void init_clock (void);
void init_uart (void);
void delay (unsigned mse);
void uart_send_string (char *data, int len);
void main (void)
{
init_clock ();
init_uart ();
memset (TxData, 0, TX_SIZE);
memcpy (TxData, TX_STRING, sizeof(TX_STRING));
while (1)
{
uart_send_string (TxData, sizeof(TX_STRING));
delay (1000);
}
}
void init_clock (void)
{
CLKCONCMD &= ~0x40;
while (CLKCONCMD & 0x40);
CLKCONCMD &= ~0x47;
}
void init_uart (void)
{
PERCFG = 0x00;
P0SEL = 0x0c;
P2DIR &= ~0xc0;
U0CSR |= 0x80;
U0GCR |= 11;
U0BAUD |= 216;
UTX0IF = 0;
IEN2 |= 0x04;
IEN0 |= 0x80;
}
void delay (unsigned mse)
{
unsigned int i,j;
for (i = 0; i < mse; i++)
for (j = 0; j < 1070; j++);
}
void uart_send_string (char *data, int len)
{
unsigned int i;
for (i = 0; i < len; i++)
{
U0DBUF = *data++;
while (UTX0IF == 0);
//UTX0IF = 0;
}
}
#pragma vector = UTX0_VECTOR
__interrupt void UART0_ISR (void)
{
UTX0IF = 0;
}