You are here

GPS integration with psoc | Cypress Semiconductor

GPS integration with psoc

Summary: 14 Replies, Latest post by DEPREDADOR1888 on 14 Jan 2016 02:19 PM PST
Verified Answers: 0
Last post
Log in to post new comments.
Nivi's picture
12 posts

hi all,
I am working on a project that requires GPS data to be read and displayed in hyperterminal window. I am having two UART modules with different baud rates. One module to read the data at the transmitting end( wireless) and the other one to bring it in hyperterminal. I have used the Rx-interrupt of the UART module. Since the GPS data is already in ASCII format, can anyone pls tell me how to read it into a char array directly? any other format is giving me garbage values at the hyperterminal.. this is the code in the interrupt function:
void interrupt()
int i;
double gps;
char *gpsstr;
gps = UARTgps_bReadRxData();
for(i=0;i UART_CPutString("\r\n Received one set of data \r\n");
for(i=0;i }
Another option is to use the szGetParam() function, but I dont understand its exact function, also- what is the meaning of the attribute- ignore characs under?
please tell me ASAP, for the deadline of this project is near..

user_119377051's picture
866 posts

Hi Nivi

Both boud rate is meet each other?

What kind of PSoC1 do you use?

On PSoC1, Interrupt routine have to save CPU context

and have to change memory bank into user program.

Did you do that?

Your interrupt routine is something odd.

You did convert the value of gps, but never write out.

And in the interrupt routine, delay loop is no good.

Meaning of "ignore characters under?"

System part of Interrupt routine is ignored these charactor.

These character is not store into user's buffer.

I recall somthing, I wouldn't like to answer for you,

Because, before, 14th Jun, you had ask something of UART,

I had answer for that, but you never respond to it.

You avoid it, these are rudeness,

Is it as usually in your country? anyway.

Nivi's picture
12 posts


Thank you for all ur replies, I am able to read the string now into a pointer. I have implemented ur suggestions regarding ISR, but I hav used a szGetRestOfParam() api instead of buffering. My coding:

if(str4 = UARTgps_szGetRestOfParams())


if( *str4 == '$')


UART_CPutString(" \r\n saved gps data \r\n"); // the uart that is used for displaying data in computer(baud:9600 bps)



UARTgps_CmdReset();// the uart used for receiving GPS data(baud:4800 bps)



Now am having another issue. I have set the size of Rx buffer as 127. I am getting only a part of the GPS string. what should i do to get the whole string? it consists of 75 characters maximum.

user_119377051's picture
866 posts


Using command buffer is good choice.

you can check existing data size, before read the data.

like this

... len= UART_bCmdLength();

... if( len>0 )

... { // read rest of data

... // reconstruct GPS data again

... // if find endof text: send it

... }

When using command buffer mode,

setting of terminater and delimiter is important.

So you can get each item of data, one by one.

use: UART_szGetParam();

For example: terminater=0x0d,

delimiter=0x32 or delimiter=','

user_460349's picture
1362 posts

As Dana mentioned, write the data in RX interrupt to a circular buffer and let the main flow to handling the reset. It is easier that way.

user_119377051's picture
866 posts

Correct previous post

"delimiter=0x32" ==> "delimiter=0x20" (one space)

Nivi's picture
12 posts

 hey, thanks ppl, m getting the GPS string completely now, but there is one thing that is very strange I am observing. 

UART_PutString() api can be assigned only to a pointer ryt.. I tried to take the latitude, longitude and time info seperately by having seperate arrays for each. the code is given below:

if(str4 = UARTgps_szGetRestOfParams())


                        if( *str4 == '$')



                        str5 = str4;

                        str5 =str5 + 3;

                        if((*str5 == 'G') && (*(str5+1) == 'G') && (*(str5+2) == 'A'))




                              str5 = str5+4;

                              while( *str5 != ',')


                              time[i] = *str5;

                              i++; str5++;


                              *ptr = str5;

                              str6 = str5+1;



                              {lat[i] = *str6; i++; str6++;}

                              str6=str6+1; h1 = *str6;




                              {lon[i] = *str7; i++; str7++;}


                              h2 = *str7;



                              UART_CPutString("GPS DATA: Location in - \r\n");

Finally, when I am printing the individual arrays using the UART_PutString() api, the time(which is saved first) array display includes the value of latitude and longitude chars also.. as if in a series.. and the latitude array display shows both latitude and longitude info together, and then the longitude display comes clean. Anyone can tell me why this is happening? My theory is that since the UART_PutString() api uses pointer of the starting location of the string, it is displaying all the information saved next to it in the memory.. Am I right? When  I increased the size of all the arrays by 1 element and assigned it to  '\0', I am able to get proper results. Also, Is there any way of controlling the location in SRAM in which our variables are saved? (In PSoC1)

user_14586677's picture
7646 posts

Normally you terminate a character array with a '/0', to tell you, and compiler,

where array ends. That also tells all the librabry functions where the string

ends. Keep in mind a string is an array of chars. So if I want a 10 char array

I declare it as myray[ 11 ] so that last char can be null character.


Yes you can force an array in memory to be at an absolute location, in Imagcraft



user_14586677's picture
7646 posts

Info that would not post, see attachment.


Regards, Dana.

user_14586677's picture
7646 posts

This might be useful to you, attached.


Regards, Dana.

user_14586677's picture
7646 posts

Some general rules of thumb in dealing with ISR's -






/* Style Definitions */
{mso-style-name:"Table Normal";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-fareast-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";

1) Do not make f() calls from within ISR unless you cannot avoid it. That

is because compiler will do a ton of saves, like full stack, etc. to make sure

it can return fully and properly. That in  turn slows machine down considerably

wasting a lot of MIPs. Look at your listing file to see what the compiler does with

your ISR code.


2) Best practice is simple, set a flag inside ISR and return to main() to process ISR.


3) Set up ISR to "fire" as infrequently as possible. If you only need ISR at a low rate,

don't  "oversample" it, that would be just a waste of MIPS.


4) Look at coding. If you have multiple ISRs, is there any ISR that can essentially

negate the need to process another pending ISR, eg. compute not when not

needed. If you have an ISR that needs a lot of MIPs occasionally, you can always

skip another pending ISR if by doing so nothing terrible happens.


5) If list file shows compiler generating wacky stuff, consider ASM for the ISR



6) Turn off optimization when first debugging ISRs, then look at it again after

optimization turned back on, to make sure compiler did not "optimize" in some

crazy jump or other unnecessary code.


7) If display issues are affected, jitter, etc.., consider creating a display buffer in

RAM. And when a write is needed first check if RAM already displaying what you

want, if so do nothing, or update RAM and write to display if needed. This some-

times can cure ISR driven display  update issues.








With respect to a simple method for handling Rx data, pass a pointer to ISR that points to a

character array, and in ISR simply write the character received via pointer, inc pointer, and return.

No delays in ISR, no tests, do that on return. Many ways of handling buffer, detect EOL or CR,

eg. termination of a line, and use that to flag processing char buffer, then clear buffer. Or use

circular buffer. There are UART project examples on opening screen of Designer that you can

look at to see how they do it.


Some additional help - USB to UART bridge, but can show you how buffer management done.


Regards, Dana.

Log in to post new comments.