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

[SOLVED] #INT_RDA not working on pic16F1509

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



Joined: 01 Mar 2010
Posts: 73

View user's profile Send private message

[SOLVED] #INT_RDA not working on pic16F1509
PostPosted: Thu Oct 19, 2017 5:29 pm     Reply with quote

Hello,

I'm having trouble generating an interrupt and reading serial data on a pic16f1509. I've got a scope on B5 and I can see the data coming in. I've also used essentially the same code on a pic16f1527 with no issues, works beautifully. I'm wondering if there's something silly I'm missing here. My code is below:

Code:


#include <16f1509.h>
#fuses NOWDT, NOLVP, PROTECT
#device ICD=TRUE
#use delay(clock=16000000, int)
#use rs232(baud=31250,parity=N,stop=1,xmit=PIN_B7,rcv=PIN_B5,bits=8, ERRORS)

unsigned char state = 1;


#INT_RDA
void RDA_isr()
{
state = getc();
}


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


while(1)
{
}
}



DETAILS:

PCM Compiler V4.140
PIC161509
Debug Mode
Target Voltage is 5V
Osc Speed 16MHz internal


Last edited by picj1984 on Mon Oct 23, 2017 2:03 pm; edited 1 time in total
picj1984



Joined: 01 Mar 2010
Posts: 73

View user's profile Send private message

PostPosted: Thu Oct 19, 2017 6:21 pm     Reply with quote

I thought I would try the kbhit() function and that works just fine. So it seems the interrupt is just not firing.... I'd really prefer to use the interrupt here for when the code gets more complex. Working code is below... any ideas??

Code:


#include <16f1509.h>
#fuses NOWDT, NOLVP, PROTECT
#device ICD=TRUE
#use delay(clock=16000000, int)
#use rs232(baud=31250,parity=N,stop=1,xmit=PIN_B7,rcv=PIN_B5,bits=8, ERRORS)

unsigned char state = 1;


void main ()
{



while(1)
{

    if(kbhit())
   {
   state = getc();
   }
}
}

temtronic



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

View user's profile Send private message

PostPosted: Thu Oct 19, 2017 7:55 pm     Reply with quote

this...
Debug Mode
... is a huge red flag for me.

Typically 'debug' adds a LOT of code so your program won't work in the 'real world'.
If using MPLAb you need to change the 'build configuration' to 'release', then recompile,burn the PIC and test....

Since I never use the ICD , I don't know what it 'adds' but presumably it'll alter your code as well....

I've always cut/compiled/test in real world...

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19569

View user's profile Send private message

PostPosted: Fri Oct 20, 2017 1:06 am     Reply with quote

This post:

<http://www.ccsinfo.com/forum/viewtopic.php?t=51711&highlight=pic16f1509>

Has a user with the same chip running INT_RDA basically OK (so it is tripping OK for him).

I would suggest though always using the UART name, rather than the pins (this ensures the hardware UART is selected). So:

#use rs232(UART1, baud=31250,parity=N,stop=1,bits=8, ERRORS)

This is equivalent to having both the pins and 'FORCE_HW' specified.

You have the external debug header?.

Have you tried the same basic test (just flash an LED when a character is seen), without the debugger?.
picj1984



Joined: 01 Mar 2010
Posts: 73

View user's profile Send private message

PostPosted: Mon Oct 23, 2017 1:37 pm     Reply with quote

Ttelmah wrote:
This post:

<http://www.ccsinfo.com/forum/viewtopic.php?t=51711&highlight=pic16f1509>

Has a user with the same chip running INT_RDA basically OK (so it is tripping OK for him).

I would suggest though always using the UART name, rather than the pins (this ensures the hardware UART is selected). So:

#use rs232(UART1, baud=31250,parity=N,stop=1,bits=8, ERRORS)

This is equivalent to having both the pins and 'FORCE_HW' specified.

You have the external debug header?.

Have you tried the same basic test (just flash an LED when a character is seen), without the debugger?.


You are incredible! I just put in #use rs232(UART1, baud=31250,parity=N,stop=1,bits=8, ERRORS) and it solved it!!

still debugging away, too! Smile

Fantastic, thank you!!
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