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

int_RDA and 18F6680

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



Joined: 24 Jun 2005
Posts: 206

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

int_RDA and 18F6680
PostPosted: Mon Oct 31, 2011 1:21 am     Reply with quote

Hi Everyone,

Lost a bit of hair over this one.
Below is a very simple bit of code,

Code:

#include <18F6680.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP,NODEBUG,NOBROWNOUT,NOMCLR
#use delay(clock=10000000)

#use rs232(baud=9600, UART1, ERRORS)

#int_rda
void serial_isr()
   {
      output_high(pin_E0);
   }

void main()
   {             
      enable_interrupts(int_rda);
      enable_interrupts(global);

      while(1)
           {   
            output_toggle(pin_E1);
            delay_ms(500);
         }
   }


If I comment out "enable_interrupts(int_rda); " everyone is happy, and I can see a nice 500ms pulse on PIN_E1 from the PIC. With the interrupt enabled, the pic will run between 500 and 2000 ms, and then just stop. PIN E0 does not go high.

I have tried to compile with 4.093, 4.057 and 3.249 and get the same result.

I will give it a try with another pic, but can someone just have a quick look over it just in case it is somthing stupid I am doing?

Thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 19433

View user's profile Send private message

PostPosted: Mon Oct 31, 2011 3:09 am     Reply with quote

Critical thing. INT_RDA, _must_, repeat _must_ read the serial data. If it doesn't, the PIC _will_ be hung when three characters are received.

However E0, should go high, but the E1 cycling would stop.
However though, the E0 pin defaults to waking up setup for PSP bus operation, so you need:

setup_psp(PSP_DISABLED);
setup_external_memory(EXTMEM_DISABLE);

at the start of main, or there is no guarantee, that you can toggle E0....

Best Wishes
Markdem



Joined: 24 Jun 2005
Posts: 206

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

PostPosted: Mon Oct 31, 2011 4:11 am     Reply with quote

Hi Ttelmah,

Thats what I thought about reading the RX buffer. I just wanted to make the test as simple as I could. In saying that, however, there is nothing that could send any data to the pic. This happens even if I disconnect the MAX232, so I can't see the buffer overflowing.

I will give the two lines of code a try tomorrow when I get to work. Might point me into the right direction.

Thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 19433

View user's profile Send private message

PostPosted: Mon Oct 31, 2011 3:43 pm     Reply with quote

If you disconnect the MAX232, you need to pull the RX line high at the PIC, and then pulse it low for a moment to test. Otherwise, if it floats low, then the buffer will overflow, while if is stays high, the interrupt will never trigger.
Obvious comment at this point, have you actually verified that you are receiving/sending data. Simple getc/putc code, rather than interrupt driven.

Best Wishes
Markdem



Joined: 24 Jun 2005
Posts: 206

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

PostPosted: Tue Nov 01, 2011 5:51 pm     Reply with quote

Hi Ttelmah,

Yes, if I have a simple kb_kit - getc, it will work fine. I can then print the data back to the PC. I am 99.99% sure that the hardware is OK.

I have now given this a test. I tied the RX pin high. PIC will still lock up! If I do the same thing with enable_interrupts(int_rda) commented out, the PIC runs fine.

I am still waiting on a new 18F6680. I can't see how it could be doing this if it is faulty, but I am running out of options.

Thanks
Markdem



Joined: 24 Jun 2005
Posts: 206

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

PostPosted: Mon Nov 14, 2011 2:58 am     Reply with quote

Right, I have now lost ALL my hair over this.

New PIC18F6680.
Disabled int_rda = no problems
Enable int_rda = lockup.

I have found somthing new with this one. If I put my finger on the MCLR pin, the PIC will come back alive!
I have tried to put it high, but it does not help. I also tried to pull it low, but that did not help.

Why would the MCLR pin have any effect on int_rda?
Anyone with any ideas? I would put a diffent PIC into the project, but the other CAN pics have different pinouts.

Thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 19433

View user's profile Send private message

PostPosted: Mon Nov 14, 2011 9:34 am     Reply with quote

It shouldn't.
_But_ MCLR, is (almost?) unique on the PIC, on having no protection if it goes above the supply rail. If it does, even fractionally/momentarily, it can trigger all sorts of odd things.
When you 'pull it high', what sort of resistance is involved?.
What is the electrical environment like close to the PIC?.

Best Wishes
Markdem



Joined: 24 Jun 2005
Posts: 206

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

PostPosted: Tue Nov 15, 2011 5:40 pm     Reply with quote

HI Ttelmah,

When I pull up I used a 4k7 resistor.
There is nothing around my bench that could be affecting it in any way. VDD is coming from a bench power supply.

I have now thrown in the towel. chucked in a PIC18F4680 with some modifications to the board (was not a hard as I thought). Nothing got changed around MCLR, just some output pins for the LCD.
Works like a champ even when I enable int_rda.
I would love to know what the hell was going on with the 6680, but I just don't have the time to keep playing with it.

I hope this helps anybody else that come across something like this.

Thanks for all the help guys.

Mark
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