利用csl库进行配置和传输数据,应该是5位数据输出,但第一次传输只有后四位,第二次传输是5位但第一位变成第一次传输的最后一位不是我要的那位数据,附上程序和结果图,求大神指点
程序:
#include <stdio.h>
#include <csl.h>
#include <csl_pll.h>
#include <csl_chip.h>
#include <csl_irq.h>
#include <csl_gpt.h>
#include <csl_uart.h>
#include <csl_uarthal.h>
/* Reference start of interrupt vector table */
/* This symbol is defined in file, vectors.s55 */
extern void VECSTART(void);
Uint16 i = 0;
Uint16 j = 0;
//Uint8 STR_LEN=5;
#define STR_LEN 5
char pbuf[5]={0x11,0x22,0x33,0x44,0x55};
CSLBool returnFlag;
/* 通过定义宏来控制两个外围存储器映射的寄存器,从而实现对GPIO口的控制 */
#define GPIODIR (*(volatile ioport Uint16*)(0x3400))
#define GPIODATA (*(volatile ioport Uint16*)(0x3401))
/*UART的中断程序*/
UART_Setup mySetup = {
75, /* input clock freq */
UART_BAUD_38400, /* baud rate */
UART_WORD8, /* word length */
UART_STOP1, /* stop bits */
UART_DISABLE_PARITY, /* parity */
UART_FIFO_DISABLE, /*DISABLE */
UART_NO_LOOPBACK, /* Loop Back enable */
};
void main(void)
{
/* Initialize CSL library - This is REQUIRED !!! */
CSL_init();
/* PLL configuration structure used to set up PLL interface */
// 主频为300Mhz
PLL_setFreq(1, 0x3, 0, 1, 3, 3, 0);
// IRQ_setVecs((Uint32)(&VECSTART));
// Uart_Config();
/* Configure UART registers using setup structure */
UART_setup(&mySetup);
/* Enable all maskable interrupts */
// IRQ_globalEnable();
// IRQ_globalDisable();
returnFlag=UART_write(&pbuf[0],STR_LEN,0);
} |