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

int RDA

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



Joined: 25 Apr 2011
Posts: 297

View user's profile Send private message

int RDA
PostPosted: Sun May 17, 2015 2:12 pm     Reply with quote

dear friends,

I am using Serial interface RS232 and I want to make interrupt when receiving data. The data received is just numbers such as

if receive 32 output_high PIN_D1
if receive 6 output_high PIN_D2
if receive 19 output_high PIN_D3

at the moment my code is:
Code:
#INT_RDA
void  RDA_isr(void)
{
   input2 = getc();
   if (input2 = 4)
   {
   printf("I received signal on PIC18F4520");
   output_toggle(PIN_E1);
   }
}


With the above code, when I send "2" the interrupt is being triggered as well and the printf is being executed and the LED toggles. Where I have mistake? I am using PIC18F4520 crystal 20MHz.
dyeatman



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

View user's profile Send private message

PostPosted: Sun May 17, 2015 3:01 pm     Reply with quote

First, you have been in this group long enough to know first off that you
don't PRINT inside of an ISR, we have repeated that here at least 100 times...

Second, you are comparing to the integer four not the ASCII four.
AND Third, (the root cause of your complaint) you are assigning (=) instead of
comparing (==) so it will be true every time.
_________________
Google and Forum Search are some of your best tools!!!!
aaronik19



Joined: 25 Apr 2011
Posts: 297

View user's profile Send private message

PostPosted: Sun May 17, 2015 3:12 pm     Reply with quote

This was just a test...this is not the actual program. Thats why i used print to know that the interrupt is executed.

when i made the == nothing happened.
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Sun May 17, 2015 3:51 pm     Reply with quote

aaronik19 wrote:
...
when i made the == nothing happened.

Of course not. You've just been told why.

Try testing the received data to see what you're comparing against.

Mike
temtronic



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

View user's profile Send private message

PostPosted: Sun May 17, 2015 6:49 pm     Reply with quote

re: ...
when I send "2"...

WHAT do YOU consider to be a "2" ? HOW did you send this "2"?

There is of course a BIG difference between an ASCII "2" and a 'real' "2". Well not that big, just 30x or 48 decimal.


Jay
ezflyr



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

View user's profile Send private message

PostPosted: Mon May 18, 2015 10:54 am     Reply with quote

Hi,

Seriously, this seems more like a lack of proper troubleshooting than anything else! For example, if you had simply done something like this, I don't think you'd be so in the dark about what's going on:

Code:

#INT_RDA
void  RDA_isr(void)
{
   input2 = getc();
   printf("Rcv. Char.: %c\n\r", input2);

   if (input2 = 4)
   {
   output_toggle(PIN_E1);
   }
}


Now, the printf inside the ISR actually does something useful, and provides you with some information about what the PIC is actually receiving! Of course, once you figure this out, don't leave the printf statement inside the ISR.

John
dyeatman



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

View user's profile Send private message

PostPosted: Mon May 18, 2015 11:43 am     Reply with quote

Of course you should understand by now we are giving you hints trying to
make you think. Hoping you can figure out some of this for yourself and
learn rather than handing you the answers and you won't learn near as
much. However, so some reason you don't seem inclined to think for
yourself....you are not even paying full attention to what we are telling you.
You have been in this forum for 4 years now and much of this you should
know by now.
_________________
Google and Forum Search are some of your best tools!!!!
aaronik19



Joined: 25 Apr 2011
Posts: 297

View user's profile Send private message

PostPosted: Mon May 18, 2015 11:38 pm     Reply with quote

Dear all, sorry for my late reply but i was without internet whole day yesterday and was unable to give reply. I found my mistake last sunday and rectified the problem immediately and worked.

Dyeatman, please stop to be personal to me. I am not full time on c, i am learning on my own and if i ask question that does not mean that i am not searching for information. If you do not want to help me, it up to you, but at least do not post personal message that i am not thinking for myself. For you some questions are "silly" but i am sure that these are questions which might be helpful for beginners.
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