现有的例程是通过串口助手发送数据给dsp再转给pc,现需要dsp单发送自身处理好的数据给pc,尝试更改URTHR(发送保持寄存器)的赋值但并未出现结果,请问按我需要的内容应该怎么改这段程序,谢谢。。。也有点疑惑如何让dsp产生的数据不断通过串口传出来而不是pc发pc收。
附上程序:
#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>
void delay(unsigned int N);
/* Reference start of interrupt vector table */
/* This symbol is defined in file, vectors.s55 */
extern void VECSTART(void);
Uint16 i = 0;
Uint16 j = 0;
Uint16 DestData,DestData1;
Uint16 DataCount=0;
Uint16 LLL=55;//假设这是dsp内部处理出来的需要发送的数据
/* 通过定义宏来控制两个外围存储器映射的寄存器,从而实现对GPIO口的控制 */
#define GPIODIR (*(volatile ioport Uint16*)(0x3400))
#define GPIODATA (*(volatile ioport Uint16*)(0x3401))
//Uint16 length = 4;
//char pbuf[4] = {0x74, 0x65, 0x73, 0x74};
//CSLBool returnFlag;
/*UART的中断程序*/
interrupt void UartIsr(void)
{
// Transimit seriz of serial debugger on pc is:
// 1112131415161718191A1B1C1D1E1F2021222324
UART_FSET(URLCR, DLAB, 0);
/* wait for RX empty */ 。。。。。。。感觉是不是改动这段。。。。。。
while(!UART_FGET(URLSR,DR));
DestData = UART_RGET(URRBR);
UART_FSET(URLCR, DLAB, 0);
UART_RSET(URTHR,LLL);
}
void Uart_Config(void)
{
/* Set BSR to disable SP2MODE */
CHIP_FSET(XBSR, SP2MODE,0) ;
/* Disable all UART events */
UART_FSET(URLCR,DLAB,0);
UART_RSET(URIER, UART_RINT);
/* Reset and disable FIFOs */
UART_RSET(URFCR, 0x7);
UART_RSET(URFCR, 0);
/* Set DLL and DLM to values appropriate for the required baudrate */
UART_FSET(URLCR, DLAB, 1); // DLAB = 1
//UART_RSET(URDLL, 0x45); // 9600bps
UART_RSET(URDLL, 0xE8); // 9600bps
UART_RSET(URDLM, 0x01);
UART_FSET(URLCR, DLAB, 0); // DLAB = 0
/* Setup word size, stop bits, parity */
UART_RSET(URLCR, 0x03); // 8 data bits, no parity, one stop bit
/* Disable loopback control */
UART_RSET(URMCR, 0);
/* UART out of reset */
UART_FSET(URPECR,URST,1);
/* Temporarily disable all maskable interrupts */
//IRQ_globalDisable();
/* Clear interrupt enable bit */
IRQ_disable(IRQ_EVT_RINT2);
/* Clear any pending Timer interrupts */
IRQ_clear(IRQ_EVT_RINT2);
/* Place interrupt service routine address at */
/* associated vector location */
IRQ_plug(IRQ_EVT_RINT2, &UartIsr);
/* Enable Timer interrupt */
IRQ_enable(IRQ_EVT_RINT2);
/* Enable all maskable interrupts */
//IRQ_globalEnable(); // IRQ_globalDisable();
}
void main(void)
{
/* Initialize CSL library – This is REQUIRED !!! */
CSL_init();
/* PLL configuration structure used to set up PLL interface */
// 主频为300Mhz
PLL_setFreq(1, 0xf, 0, 1, 3, 3, 0);
IRQ_setVecs((Uint32)(&VECSTART));
Uart_Config();
/* Enable all maskable interrupts */
IRQ_globalEnable();
// returnFlag = UART_write(&pbuf[0],length,0);
for(;;)
{
for(i=0; i<16; i++)
{
delay(300);
}
}
}
void delay(unsigned int N)
{
unsigned int i,j;
for(i=0;i<N;i++)
for(j=0;j<N;j++)
asm(" nop");
}
Shine:
请问你的问题是DSP数据发不出数据给PC吗?还是PC端显示不正确?
jia ji:
回复 Shine:
之前是发布出去,这个问题已经解决了,谢谢!