Other Parts Discussed in Thread: OMAPL138
Hello,
I'm working on OMAPL138, In that externally we were using GNSSmodule(S1216F8‐GI3) through UART0 I'm transmitting with a specific baud rate of 115200, but I can't receiving data from the console.
For transmitting purpose I have taken the UART0 and receiving from UART2 both baud rate should same 115200.
#include <header/hw_psc_OMAPL138.h>
#include <header/hw_types.h>
#include <header/interrupt.h>
#include <header/lcdkOMAPL138.h>
#include <header/psc.h>
#include <header/soc_OMAPL138.h>
#include <header/uart.h>
void GNSS(void);
void UartInit0(void);
void UartInit2(void);
void delay_ms(unsigned int ms);
void UartString(unsigned char *Str);
unsigned char Gpsdata; // for incoming serial data
unsigned int finish = 0; // indicate end of message
unsigned int pos_cnt = 0; // position counter
unsigned int lat_cnt = 0; // latitude data counter
unsigned int log_cnt = 0; // longitude data counter
unsigned int flg = 0; // GPS flag
unsigned int com_cnt = 0; // comma counter
unsigned char latitude[20]; // latitude array
unsigned char longituted[20]; // longitude array
char byteTx = 0;
char ch = 0;
int ival = 0;
int count = 0;
unsigned int config = 0;
unsigned char command[] = "$GPGAG:- ";
int main(void)
{
UARTStdioInit();
UARTPuts("\n---------------------------------------------------\r\n", -1);
UARTPuts("\n\nTest Description.\r\n", -1);
UARTPuts("This Code Will Configure GNSS(GPS) peripheral to measure.\r\n", -1);
UARTPuts("Latitude and Longitude and Display the information using .\r\n", -1);
UARTPuts("UART Peripheral available with LCDKOMAPL138 board\r\n", -1);
UARTPuts("\n---------------------------------------------------\r\n" , -1);
UartInit0();
delay_ms(500);
UartInit2();
delay_ms(500);
while (1)
{
// printf("Gpsdata\n");
Gpsdata = UARTCharGetNonBlocking(SOC_UART_0_REGS);
printf ("%c\n",Gpsdata);
#if 0
GNSS();
UartString(command);
UartString(latitude);
UARTCharPut(SOC_UART_2_REGS, ',');
UARTCharPut(SOC_UART_2_REGS, 'N');
UARTCharPut(SOC_UART_2_REGS, ',');
UartString(longituted);
UARTCharPut(SOC_UART_2_REGS, ',');
UARTCharPut(SOC_UART_2_REGS, 'E');
UARTCharPut(SOC_UART_2_REGS, '\n');
UARTCharPut(SOC_UART_2_REGS, '\r');
#endif
//delay_ms(10000);
}
}
/*****************************************************************************
**@name : GNSS();
*
**@brief : GNSS Function to Calculate the Latitude and Longitude.
*
**@param : void
*
**@return : 0
****************************************************************************/
void GNSS(void)
{
while (finish == 0)
{
Gpsdata = UARTCharGet(SOC_UART_0_REGS);
flg = 1;
/* finding GNGLL header */
if (Gpsdata == '$' && pos_cnt == 0)
pos_cnt = 1;
if (Gpsdata == 'G' && pos_cnt == 1)
pos_cnt = 2;
if (Gpsdata == 'P' && pos_cnt == 2)
pos_cnt = 3;
if (Gpsdata == 'G' && pos_cnt == 3)
pos_cnt = 4;
if (Gpsdata == 'L' && pos_cnt == 4)
pos_cnt = 5;
if (Gpsdata == 'L' && pos_cnt == 5)
pos_cnt = 6;
if (pos_cnt == 6 && Gpsdata == ',')
{ /* count commas in message */
com_cnt++;
flg = 0;
}
if (com_cnt == 1 && flg == 1)
{
/* Latitude */
latitude[lat_cnt++] = Gpsdata;
flg = 0;
}
if (com_cnt == 3 && flg == 1)
{
/* Longitude */
longituted[log_cnt++] = Gpsdata;
flg = 0;
}
if (Gpsdata == '*' && com_cnt >= 3 && flg == 1)
{
latitude[lat_cnt] = '\0'; // end of GNGLL message
longituted[log_cnt] = '\0';
com_cnt = 0; // end of GNGLL message
lat_cnt = 0;
log_cnt = 0;
flg = 0;
finish = 1;
}
}
finish = 0;
pos_cnt = 0; /* Setting the UART Receiver Trigger Level*/
UARTFIFOLevelSet(SOC_UART_2_REGS, UART_RX_TRIG_LEVEL_1);
}
/*****************************************************************************
**@name : UartInit0();
*
**@brief : This function will initialize UART0 Peripheral available with
* : LCDKOMAPL138 board. to receive data from GNSS device.
*
**@param : void
*
**@return : 0
****************************************************************************/
void UartInit0(void)
{
PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_UART0, PSC_POWERDOMAIN_ALWAYS_ON,
PSC_MDCTL_NEXT_ENABLE);
/* Setup PINMUX */
UARTPinMuxSetup(0, FALSE);
/* Enabling the transmitter and byteTx = Command[ival];*/
UARTCharPutNonBlocking(SOC_UART_2_REGS, Gpsdata);
UARTEnable(SOC_UART_0_REGS);
/* 1 stopbit, 8-bit character, no parity */
config = UART_WORDL_8BITS;
/* Configuring the UART parameters*/
UARTConfigSetExpClk(SOC_UART_0_REGS, SOC_UART_0_MODULE_FREQ, 115200,
config, UART_OVER_SAMP_RATE_16);
/* Enabling the FIFO and flushing the Tx and Rx FIFOs.*/
UARTFIFOEnable(SOC_UART_0_REGS);
/* Setting the UART Receiver Trigger Level*/
UARTFIFOLevelSet(SOC_UART_2_REGS, UART_RX_TRIG_LEVEL_1);
}
/*****************************************************************************
**@name : UartInit2();
*
**@brief : This function will initialize UART2 Peripheral available with
* : LCDKOMAPL138 board. to receive data from UART0 and display
* : on serial console.
*
**@param : void
*
**@return : 0
****************************************************************************/
void UartInit2(void)
{
/* Enabling the PSC for UART2.*/
PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_UART2, PSC_POWERDOMAIN_ALWAYS_ON,
PSC_MDCTL_NEXT_ENABLE);
UARTPinMuxSetup(2, FALSE);
/* Enabling the transmitter and byteTx = Command[ival];
UARTCharPutNonBlocking(SOC_UART_2_REGS, byteTx);receiver*/
UARTEnable(SOC_UART_2_REGS);
/* 1 stopbit, 8-bit character, no parity */
config = UART_WORDL_8BITS;
/* Configuring the UART parameters*/
UARTConfigSetExpClk(SOC_UART_2_REGS, SOC_UART_2_MODULE_FREQ, BAUD_115200,
config, UART_OVER_SAMP_RATE_16);
UARTFIFOEnable(SOC_UART_2_REGS);
UARTFIFOLevelSet(SOC_UART_0_REGS, UART_RX_TRIG_LEVEL_1);
}
/*****************************************************************************
**@name : delay_ms();
*
**@brief : User Specific delay
*
**@param : void
*
**@return : 0
****************************************************************************/
void delay_ms(unsigned int ms)
{
int ival, jval;
for(ival = 0; ival < ms ; ival++)
for (jval = 0; jval < 252 ;jval++);
}
Thanks in advance
Regards,
Seyed