CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Problem with pic18f2550
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon May 23, 2022 9:24 am     Reply with quote

The ISR should only load the one character it receives into the array,update the index counter, then leave.

If I'm reading it right, the way you have coded, triggers on the 1st incoming character, then stays in a loop for 298 characters. Maybe you get them maybe you don't ? What if the device only sends 200 ? or the 'link' is broken ? If the PIC is stuck in this 'loop', it can't do anything until ALL 298 are in ?

Have a look at the CCS 'ex_sisr.c' as well as the 'timed serial' in the FAQ section. Ideally any/all serial communications should be an ISR with a 'timed response'. Decide what time it'll take for the maximum data to come in, double that, and set the 'timed counter' to that value. IE: At 9600 baud, a character comes in +- 1 ms, say you expect 44 characters, 44x2=88. Set the timed counter variable to 88ms. This way you either get all 44 characters or a timed out flag is set AND you EXIT the 'timed receive serial' function... allowing your program to continue.

In the good old days , some tech would not screw in the DB-25 connectors, so it could magically wiggle free, and you'd wonder WHY doesn't this work ??? Having a 'timed serial' ensures the program CAN carry on and TELL you WHY it possibly failed.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Mon May 23, 2022 11:50 am     Reply with quote

A flag is a term for any single bit that can be set to say something has
happened.
In the context of your code, a int1 variable that can be TRUE or FALSE.

Lots of comments.
298 characters!. No standard GPS returns a packet this long. The NMEA
standard restricts the maximum packet length to 255 characters. With
every option enabled.

However long the packet, the interrupt says _one_ character is available
_only_. It must only handle this one character. You should never do this
type of thing by counts, instead _look_ for what marks the end of the
packet. For NMEA GPS's, the start of the packet is marked by $, and the
end by a line feed.
So put one character into the buffer and exit.. When this is a line feed,
set a flag to say you have a packet.
ILLIAS28



Joined: 11 Jan 2011
Posts: 42

View user's profile Send private message

PostPosted: Tue May 24, 2022 5:33 pm     Reply with quote

Thank you very much all of you for your help.
Now it's more clear how i should use the interrupt to read data sent by GPS.
A sentence of NMEA starts with $ and ends with line feed. So i can save in arrays the sentences i need, for example $GPGGA and $GPRMC, and then parse them as i like. I will try to do all of this and give feedback later.
_________________
i am newbe
dyeatman



Joined: 06 Sep 2003
Posts: 1910
Location: Norman, OK

View user's profile Send private message

PostPosted: Wed May 25, 2022 5:27 am     Reply with quote

You might search for GPS in the CCS Code Library to get ideas.
_________________
Google and Forum Search are some of your best tools!!!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group