Hallo alle zusammen,
Ich habe eine Frage:
Ich will mit der TMS320C2000 Experiment Kit einen Menu mit einem
Terminal Programm schreiben.
Da es in der Lib von Ti zwei fertige Methode gibt, die ich gerne
benutzen möchte aber ich weiss es nicht wie ich das ambesten machen
sollte.
Die Methoden, die ich brauche habe ich importiert wie folgende:
//
extern void SetupSerialPort(void);
extern void SCITransmitByte(unsigned char data);
extern unsigned char SCIReceiveByte(void);
//
diese Methoden stammen aus der Lib "SerialPortDrv.c"
--> hier ist die Datei:
#include "DSP28x_Project.h"
//----------------------------------------------------------------------
-----
// For Portability, User Is Recommended To Use the C99 Standard integer
types
//
#include <assert.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
extern uint32_t McuE_GetSystemClock();
// ******************************************************
// bool SciDataAvailable()
//
// This function is used to check if there is any data
// in the serial port receive fifo.
//
// Return values:
// true : There is one or more bytes in the fifo buffer
// false: The fifo buffer is empty
// ******************************************************
int SCIDataAvailable()
{
return ((SciaRegs.SCIFFRX.all & 0x1F00)!=0);
}
// ******************************************************
// unsigned char SCIReceiveByte()
//
// This function is used to receive a single byte from
// serial ports receive fifo buffer.
//
// Return values:
// The first (oldest) byte in the fifo buffer
// ******************************************************
unsigned char SCIReceiveByte()
{
return SciaRegs.SCIRXBUF.all;
}
// ******************************************************
// void SCITransmitByte(unsigned char data)
//
// This function is used to transmit a single byte on
// the serial port.
//
// Parameters:
// data: The byte to transmit.
// ******************************************************
void SCITransmitByte(unsigned char data)
{
//Note: Some TI DSPs have smaller IO buffers. Use 0x0300 for these
//1. If the fifo buffer is full we should wait
while((SciaRegs.SCIFFTX.all &0x1F00)>0x0300) ;
//while((SciaRegs.SCIFFTX.all &0x1F00)>0x0C00) ;
//kickdog();
//2. Write the data byte to the fifo buffer
SciaRegs.SCITXBUF=data;
}
void SetupSerialPort()
{
uint32_t SystemClockFrequency = McuE_GetSystemClock();
// *** Calculate the BRR ***
//
// CPUCLK>>LOW_SPEED_CLOCK_DIVIDER
// BRR = ---------------------------------- - 1
// 8*BAUDRATE
/* Low speed clock = 15 MHz (60/4 MHz), Baudrate = 115200 baud */
//uint32_t BRR = (60000000UL >> (SysCtrlRegs.LOSPCP.all))/(115200<<3)
- 1;
//uint32_t BRR = (SystemClockFrequency >>
(SysCtrlRegs.LOSPCP.all))/(921600<<3) - 1;
uint32_t BRR = (SystemClockFrequency >>
(SysCtrlRegs.LOSPCP.all))/(115200<<3) - 1;
EALLOW;
SciaRegs.SCICTL1.all=0x0003; // Reset SCI
SciaRegs.SCIFFTX.all=0xE040;
SciaRegs.SCIFFRX.all=0x2044;
SciaRegs.SCIFFCT.all=0x0;
SciaRegs.SCICTL2.all=0x0000;
// Set the baud rate
SciaRegs.SCIHBAUD=(uint16_t)(BRR>>8) & 0xFF;
SciaRegs.SCILBAUD=(uint16_t)BRR & 0xFF;
SciaRegs.SCIPRI.all=0x0018;
SciaRegs.SCICCR.all=0x0007; // 8 bit character length, No parity, 1
stop bit
SciaRegs.SCICTL1.all=0x0023; // Enable the SCI
EDIS;
}
--> mein main()Methode sieht so aus:
void main (void)
{
INT32U SystemClockFrequency;
INT16U i;
// Init BSW drivers
EcuM_InitDrivers();
// For Debug - I/O
SetupSerialPort();
// Sign-on
SystemClockFrequency = McuE_GetSystemClock();
#pragma diag_suppress 183
LDEBUG_PRINTF("BSW_MCU: %s Clock: %08ul\n", CORE_CPU_DESCRIPTION,
SystemClockFrequency);
#pragma diag_default 183
i = 0;
while (true)
{
printf("***Hello Word*****! %d\r\n", i++);
DELAY_US(500000); // .5 sec
}
}
bis dahin funktioniert alles nur weiss ich leider nicht wie ich einen
Menu schreibe mit Hilfe der beide Methode :
SCITransmitByte(unsigned char data)
und
unsigned char SCIReceiveByte().