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 CCS Technical Support

help

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
NAVID



Joined: 14 Jun 2017
Posts: 28

View user's profile Send private message Send e-mail

help
PostPosted: Mon Aug 28, 2017 10:03 am     Reply with quote

hi every one
I want to send characters to pic 16f877a by hc-05 and i do this correctly. Then i want to when pic receive "^" show characters but it does not work.
I don't know why but i hope somebody can help me. This is my program:
Code:

#include <main.h>
#include "lcd_flex.c"
#include <string.h>

int1 b=0,step=0;
int8 rec,a[11];
char c[1]='^';
//char d[1];

#INT_TBE
void  TBE_isr(void)
{

}

#INT_RDA
void  RDA_isr(void)
{
for(rec=0;rec<10;rec++){
a[rec]=getc();
 if(strcmp(c,a[rec])==1){
  step=1;} }
 step=1;
}

void main()
{
  // enable_interrupts(INT_TBE);
   enable_interrupts(INT_RDA);
   enable_interrupts(GLOBAL);

lcd_init();

   while(TRUE)
   {
   if(b==0){
     lcd_gotoxy(1,1);
     lcd_putc("hi lets start");
     delay_ms(1000);
     lcd_clear();
     b=1;}
 
 if(step==1){
     lcd_clear();
     lcd_gotoxy(1,1);
     printf(lcd_putc,"%s             ",a);
     step=0; }
   }

}

Exclamation Question
temtronic



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

View user's profile Send private message

PostPosted: Mon Aug 28, 2017 10:13 am     Reply with quote

this line...
Quote:

if(strcmp(c,a[rec])==1){
says IF the a[rec] value is equal to the value of variable c, then do something.

However you've got an ARRAY called C, not a simple variable called C.

It should work though, as
Quote:

if(strcmp(c(0),a[rec])==1){

providing the FIRST array location is C(0) and not c(1).

Really the 'test variable' ("^") should be just a character variable perhaps named caret.

There are other problems in your code.
For one, do not use the xmt ISR, not really needed.
The receive ISR only fires on ONE incoming character.
I suggest you look at the CCS supplied example program call ex_sisr.c in the 'examples' folder for how to receive a 'string' of characters.

Jay
NAVID



Joined: 14 Jun 2017
Posts: 28

View user's profile Send private message Send e-mail

PostPosted: Mon Aug 28, 2017 11:18 am     Reply with quote

Thank you, I will go to look at the example and come back to ask some questions later ((:
NAVID



Joined: 14 Jun 2017
Posts: 28

View user's profile Send private message Send e-mail

PostPosted: Tue Aug 29, 2017 11:14 am     Reply with quote

temtronic wrote:

There are other problems in your code.
For one, do not use the xmt ISR, not really needed.

hi again
what is the xmt ISR ??
temtronic



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

View user's profile Send private message

PostPosted: Tue Aug 29, 2017 2:15 pm     Reply with quote

this ....
Quote:

#INT_TBE
void TBE_isr(void)
{

}

...is the xmt ISR ( transmit ISR )

It's only 5 lines of code, not being used in your program so just delete it.

Jay
ezflyr



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

View user's profile Send private message

PostPosted: Thu Aug 31, 2017 1:29 pm     Reply with quote

Hi,

It hasn't been mentioned yet, but your Rx interrupt (#INT_RDA) construct is totally wrong. The serial interrupt fires for each character that is received, so you should read one - and only one - character inside the ISR. Put these characters inside an array, and process the array in Main() once the entire transmission is received. Don't read multiple characters inside the ISR!
_________________
John

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



Joined: 14 Jun 2017
Posts: 28

View user's profile Send private message Send e-mail

PostPosted: Sat Sep 02, 2017 11:19 pm     Reply with quote

ezflyr wrote:
Hi,

It hasn't been mentioned yet, but your Rx interrupt (#INT_RDA) construct is totally wrong. The serial interrupt fires for each character that is received, so you should read one - and only one - character inside the ISR. Put these characters inside an array, and process the array in Main() once the entire transmission is received. Don't read multiple characters inside the ISR!


Hi, thanks.
So what i must going to do??
Can you write for me an example??
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Sun Sep 03, 2017 1:19 am     Reply with quote

ex_sisr.c, shows how a serial receive routine should be done.

There have also been lots of examples here.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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