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

RDA2 interruption
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
SQR-1



Joined: 28 Mar 2019
Posts: 10

View user's profile Send private message

PostPosted: Mon May 06, 2019 10:34 am     Reply with quote

ok ... it seems he has found the problem ...
In port definitions, "FIXED_IO" is used for port G. In addition to being RS-232, the rest of the pins are also used as inputs ... now "FAST_IO" is used to define G and seems to work (I do not understand Well, it's the difference but it works)
Now I wonder how to read the input strings until I receive an "enter" and try them ... but it will be a topic for tomorrow ... again I will rest and sleep ... ;-)

#include <18F67K40.h>

#device ADC=10
#use delay(crystal=20000000)
#use FIXED_IO( A_outputs=PIN_A3,PIN_A5)
#use FIXED_IO( B_outputs=PIN_B3,PIN_B4,PIN_B5)
#use FIXED_IO( C_outputs=PIN_C0,PIN_C1,PIN_C2,PIN_C5)
#use FIXED_IO( D_outputs=PIN_D6,PIN_D7)
#use FIXED_IO( E_outputs=PIN_E0,PIN_E1)
#use FIXED_IO( F_outputs=PIN_F1,PIN_F2,PIN_F3,PIN_F4,PIN_F5,PIN_F6 )
//#use FIXED_IO( G_outputs=PIN_G0,PIN_G1,PIN_G3, PIN_G4 )
#use fast_io(G)
#use FIXED_IO( H_outputs=PIN_H0,PIN_H1)
ezflyr



Joined: 25 Oct 2010
Posts: 1012
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Mon May 06, 2019 12:29 pm     Reply with quote

Hi,

The issue you encountered is exactly why you should not be messing with compiler directives you aren't familiar with! Standard I/O is the default I/O configuration mode, and is just fine in 99% of all projects! With Standard I/O the compiler will automatically configure I/O ports based on the other code you write. For example, the use of the 'output_toggle' command will automatically set that pin as an output.

Get rid of all that #Use Fixed_IO stuff as it's just causing you headaches with no benefit!
_________________
John

If it's worth doing, it's worth doing in real hardware!
temtronic



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

View user's profile Send private message

PostPosted: Mon May 06, 2019 12:56 pm     Reply with quote

In the 1/4 century that I've been 'playing with PIC's, I've only needed to use FAST-IO() twice. In both cases it was to maximize the PIC's performance to interface with custom, proprietary equipment probably 18-20 years ago, Twice...that's it. Dozens of clients, hundreds of projects. Today's PICs run a LOT faster, so I don't even have to think 'should I use FAST_IO() ?'. The answer would be no.

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 14406

View user's profile Send private message

PostPosted: Mon May 06, 2019 1:48 pm     Reply with quote

and, 'fixed_io', does not give any speed gain over the standard I0 mode, so
is pretty much useless...
SQR-1



Joined: 28 Mar 2019
Posts: 10

View user's profile Send private message

PostPosted: Mon May 06, 2019 2:35 pm     Reply with quote

Thank you for all this valuable information ... in my case I use this because I do not know any other method and I do not know what to say when I decide standard io... what is the correct way to configure the ports?
Thank you
temtronic



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

View user's profile Send private message

PostPosted: Mon May 06, 2019 4:28 pm     Reply with quote

standard_io() is the compiler's default setting and you don't have to do anything!!! It will make the appropriate changes, as required.
Simply delete the fast_IO() lines of code and the tris setups...
It's just one of the nice features of the CCS compiler !
dluu13



Joined: 28 Sep 2018
Posts: 198
Location: Toronto, ON

View user's profile Send private message Visit poster's website

PostPosted: Mon May 06, 2019 6:30 pm     Reply with quote

For capturing your messages, I would set up a char array. Then each time a char comes in on your RDA interrupt, you grab it and place it into your array and then increment the pointer. If the char is a newline, then set a flag and let your main loop process your message that's in the array. Finally, reset your pointer to the beginning of the array and you are ready to receive your next message.
SQR-1



Joined: 28 Mar 2019
Posts: 10

View user's profile Send private message

PostPosted: Tue May 07, 2019 2:07 am     Reply with quote

Perfect ... I can already store the data that arrives through the serial port ... when the "enter" (13) arrives I put a dashboard to call the comparison function ... but now I do not know how to compare the content of the chain with another from the memory for example "CISCO INPUT"
Code:

void tratamiento_cadenas()
{
for(aa=0; aa<contador_serie; aa++)
{putc(Datos_Pacom[aa]);}

putc(13);putc(10);

for(aa=0; aa<100; aa++)
{Datos_Pacom[aa]=0;}          // borra la cadena antes de salir
contador_serie=0;
fin_trans=0;
}

#int_rda2
SerialDataReceive(void)
{
Byte_IN=getc();
Datos_Pacom[contador_serie]=Byte_IN;
contador_serie=contador_serie+1;
if (Byte_IN==13){fin_trans=1;}
}
ezflyr



Joined: 25 Oct 2010
Posts: 1012
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Tue May 07, 2019 10:09 am     Reply with quote

Hi,

A couple of things to note:

1. This forum is exclusively conducted in the English language. I appreciate that it's probably not your native language, but you really should comment your code in English as well if you want the best possible help!

2. You really need to watch for a 'Start' character in addition to the 'End' character, which in this case is the <CR>. This allows you to definitely capture an entire transmission without ambiguity! As an example, GPS receivers universally transmit NMEA format data which begins with a '$', and ends with a <CR>. Very easy to capture! So, inside your serial ISR, read characters until the 1st Start character is received, and then buffer everything until the <CR> is received. At this point you know you have the full 'message'.
_________________
John

If it's worth doing, it's worth doing in real hardware!
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