Hello!
I wanted to implement basic uart.
This is the program that I've written. I'm stuck on how to display the values of different variables by using %d, %s etc.
In the program below, I've printed a basic string.
//
// Included Files
//
#include "driverlib.h"
#include "device.h"
#include "board.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
//
// Globals
//
uint16_t loopCount;
uint16_t errorCount;
//
// Function Prototypes
//
void error();
void uart(char[],int);
//
// Main
//
void main(void)
{
char send[256] = "Hello Everyone!\n";
//
// Initialize device clock and peripherals
//
Device_init();
//
// Setup GPIO by disabling pin locks and enabling pullups
//
Device_initGPIO();
//
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// Board Initialization
//
Board_init();
//
// Enables CPU interrupts
//
Interrupt_enableGlobal();
//
// Send a character starting with 0
//
//sendChar = 0;
//
// Send Characters forever starting with 0x00 and going through 0xFF.
// After sending each, check the receive buffer for the cSCIorrect value.
//
for(;;)
{
uart(send,sizeof(send));
}
}
void uart(char name[],int a)
{
uint16_t sendChar;
uint16_t receivedChar;
uint8_t i;
char each;
for( i = 0; i<a; i++)
{
each = name[i];
sendChar = (uint16_t)each;
SCI_writeCharNonBlocking(mySCI0_BASE, sendChar);
//
// Wait for RRDY/RXFFST = 1 for 1 data available in FIFO
//
while(SCI_getRxFIFOStatus(mySCI0_BASE) == SCI_FIFO_RX0)
{
;
}
//
// Check received character
//
receivedChar = SCI_readCharBlockingFIFO(mySCI0_BASE);
//
// Received character not correct
//
if(receivedChar != sendChar)
{
asm(" ESTOP0"); // Uncomment to stop the test here
for (;;);
}
}
}
//
// End of file
//
output: