Haberler:

Forum kuralları güncellendi LÜTFEN  okuyunuz:  https://bit.ly/2IjR3ME

Ana Menü

GPS MODÜLÜ ACİL!!!!

Başlatan byclgn, 27 Eylül 2013, 15:58:18

byclgn

FGPMMOPA6B   GPS mi modemiyle çalışıyorum rs  uart 0 a bağlı   


gps ise uart 3 'e    uart3 den gps verisi çekip uart 3 E gönderiyorum ama bir türlü mantıklı veriler alamıyorum

işlemci lpc1768   
gps enable  p2.6 da



Alıntı Yap#include "lpc17xx.h"
#include "lpc17xx_uart.h"
#include "lpc17xx_libcfg.h"
#include "lpc17xx_libcfg_default.h"
#include "lpc17xx_pinsel.h"
#include "lpc17xx_gpio.h"
////////////////////////////////////
void DelayMs(long);
void init3(void);
void init0(void);
//////////////////////////////////
void DelayMs(long ms)

{
long i; int j;
for (i = 0; i < ms; i++ )
for (j = 0; j < 7500; j++ );
}


void init3(){
   
   UART_CFG_Type UARTConfigStruct;
   PINSEL_CFG_Type PinCfg;
   
   PinCfg.Funcnum = 3;
   PinCfg.OpenDrain = 0;
   PinCfg.Pinmode = 0;
   PinCfg.Portnum = 4;
   PinCfg.Pinnum = 28;
   PINSEL_ConfigPin(&PinCfg);
   PinCfg.Pinnum = 29;
   PINSEL_ConfigPin(&PinCfg);

/*
    Initialize UART Configuration parameter structure to default state:
    * Baudrate = 9600bps
    * 8 data bit
    * 1 Stop bit
    * None parity
    */
   UART_ConfigStructInit(&UARTConfigStruct);
   // Re-configure baudrate to 115200bps
   UARTConfigStruct.Baud_rate = 19200;

   // Initialize DEBUG_UART_PORT peripheral with given to corresponding parameter
   UART_Init(LPC_UART3, &UARTConfigStruct);

   // Enable UART Transmit
   UART_TxCmd(LPC_UART3, ENABLE);



}
void init0(){

   UART_CFG_Type UARTConfigStruct;
   PINSEL_CFG_Type PinCfg;
   PinCfg.Funcnum = 1;
   PinCfg.OpenDrain = 0;
   PinCfg.Pinmode = 0;
   PinCfg.Pinnum = 2;
   PinCfg.Portnum = 0;
   PINSEL_ConfigPin(&PinCfg);
   PinCfg.Pinnum = 3;
   PINSEL_ConfigPin(&PinCfg);
/*
    Initialize UART Configuration parameter structure to default state:
    * Baudrate = 9600bps
    * 8 data bit
    * 1 Stop bit
    * None parity
    */
   UART_ConfigStructInit(&UARTConfigStruct);
   // Re-configure baudrate to 115200bps
   UARTConfigStruct.Baud_rate = 19200;

   // Initialize DEBUG_UART_PORT peripheral with given to corresponding parameter
   UART_Init(LPC_UART0, &UARTConfigStruct);

   // Enable UART Transmit
   UART_TxCmd(LPC_UART0, ENABLE);

}


int main(){

   uint8_t len,buffer[10],i,idx;
GPIO_SetDir(2,1<<6,1);
   GPIO_ClearValue(2,1<<6);


   init0();
   init3();
   

   

   
   GPIO_SetValue(2,1<<6);
   
   while(1){
      len=UART_Receive(LPC_UART3, buffer,sizeof(buffer),NONE_BLOCKING);
               DelayMs(10);
     UART_Send(LPC_UART0,buffer,len, BLOCKING);
            
          } 
         
         
          /*
   while(1){
       len = 0;
        while (len == 0)
        {
            len = UART_Receive(LPC_UART3, buffer, sizeof(buffer), NONE_BLOCKING);
        }

        / Got some data /
        idx = 0;
        while (idx < len)
        {
           
               Echo it back
               UART_Send(LPC_UART0, &buffer[idx], sizeof(buffer), BLOCKING);
           
            idx++;
        }
         } */
      
   /*   delay(300);
   rec=0;
   rec=UART_Receive(LPC_UART3, (uint8_t*)rxbuf,sizeof(rx0buf),NONE_BLOCKING);
       if(rec>0)
               UART_Send(LPC_UART0,(uint8_t*)rxbuf,rec, BLOCKING);
      */
while(1);
   }







lütfen yardım



leblebitozu

Default baudrate 9600 görünüyor datasheet'te, kod da 19200.

byclgn

veriyi tam almak için buffer ı nasıl yazmam gerekiyor

tesladream

#3
Temp diye bir buffer ayarla USART receive ederken bu tempi doldur aynı zamanda senin için gereken NMEA verisini tempin içinden çek ayrı bir buffer a yaz sonra işin kolaylaşıcak.Tek bir NMEA datası CheckSum a kadar sanırım 70 byte kadar sen bir 500 byte yap tempi.Ben aşağıdaki interrupt rutini kullanıyorum.İnş işine yarar.Kolay gelsin.
void USART3_IRQHandler(void)
{
	volatile int Sts;
	Sts=USART3->SR;
		temp[cnt] = USART3->DR;	  
	  if((cnt>=5)&& temp[cnt]=='C' && temp[cnt-1]=='M' && temp[cnt-2]=='R' && temp[cnt-3]=='P' && temp[cnt-4]=='G' && temp[cnt-5]=='$')
		{
			for(j=0;j<6;j++) RxBuf[j]=temp[cnt+j-5];
			rmc=1;
		}
		if(rmc==1)
		{
			RxBuf[j-1]=temp[cnt];
			j++;
			if(temp[cnt]=='*'){msg=1;}			
		}	
    cnt++;		
		if(cnt==0x1E8) cnt=0;
}