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

18F46K22 #INT_RDA2 not triggering [SOLVED]

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



Joined: 01 Jan 2007
Posts: 38
Location: Mississauga, Ontario, Canada

View user's profile Send private message

18F46K22 #INT_RDA2 not triggering [SOLVED]
PostPosted: Fri Apr 21, 2017 5:55 pm     Reply with quote

Hi everyone,

I can't seem to crack this. Running version 5.071, 18F46K22 and I've tried numerous development boards. It seems I am able to capture #INT_RDA interrupts, but not #INT_RDA2 interrupts. All 5 volt operation. Tried different crystal speeds and other boards that use oscillators.

I've built a simple program using CCS project wizard to illustrate. The operation is simple, if a byte is received on UART1, RB1 LED will toggle on/off per character -- same operation for UART2, but RB2 toggles on and off - Trouble is, UART2 / #INT_RDA2 do not seem to work.

There have been some helpful posts in the forum, however I am still struggling with this unfortunately.

I have confirmed that UART1 uses PINs RC7/RC6, and UART2 uses PINs RB7/RB6. Knowing that the ICD uses RB7/RB6, I have disconnected the programmer while doing my character tests. I am using different sources of serial data; GPS module, and a simple PC RS232 to TTL handy dandy module.

UART1 toggles the LED fine, UART2 doesn't do anything.

Below is the code;

MAIN.C

Code:
#include <main.h>

#INT_RDA
void  RDA_isr(void)
{
   output_toggle(SERIAL_LED_1);
   c=fgetc(PORT1);
}

#INT_RDA2
void  RDA2_isr(void)
{
   output_toggle(SERIAL_LED_2);
   c=fgetc(PORT2);
}

void main()
{

   enable_interrupts(INT_RDA);
   enable_interrupts(INT_RDA2);
   enable_interrupts(GLOBAL);

   while(TRUE)
   {

      //Example blinking LED program
      output_low(LED);
      delay_ms(DELAY);
      output_high(LED);
      delay_ms(DELAY);

      //TODO: User Code
   }

}


MAIN.H

Code:
#include <18F46K22.h>
#device ADC=10

#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOPBADEN                 //PORTB pins are configured as digital I/O on RESET
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)

#use delay(crystal=25MHz)
#use rs232(baud=9600,parity=N,UART1,bits=8,stream=PORT1)
#use rs232(baud=9600,parity=N,UART2,bits=8,stream=PORT2)

#define LED PIN_B0
#define SERIAL_LED_1 PIN_B1
#define SERIAL_LED_2 PIN_B2
#define DELAY 50

char c; // temporary serial character buffer


Last edited by maxrate on Fri Apr 21, 2017 7:56 pm; edited 1 time in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 21, 2017 7:23 pm     Reply with quote

Quote:
#include <18F46K22.h>
#device ADC=10

#FUSES NOBROWNOUT //No brownout reset
#FUSES NOPBADEN //PORTB pins are configured as digital I/O on RESET
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)

#use delay(crystal=25MHz)

Are you actually using a 25 MHz crystal on the board ?
According to Table 27-7,
Quote:
TABLE 27-7: EXTERNAL CLOCK TIMING REQUIREMENTS
For HS mode, the maximum crystal frequency allowed is 20 MHz.

See page 436 in the 18F46K22 data sheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/40001412G.pdf
maxrate



Joined: 01 Jan 2007
Posts: 38
Location: Mississauga, Ontario, Canada

View user's profile Send private message

PostPosted: Fri Apr 21, 2017 7:37 pm     Reply with quote

Hello PCM Programmer - thank you for your reply.

I am using a 25 Mhz crystal, I have tried 4 Mhz crystals as well (and other dev boards). Because of your suggestion, I've just installed a 12 Mhz crystal, recompiled and tested - same result unfortunately.

I wanted to add that with my testing, I am sending only a few characters (keystrokes mostly) as my data source, and I am not sending characters to the two UARTS simultaneously. I am trying one at a time, very basic testing.

Still a mystery to me. I strongly feel I've covered all of the basics. I've tried other dev boards, oscillators, crystals, different PIC18F46K22 chips, different sources of serial data, different baud rates (down to 2400 baud), unplugging the ICD programmer.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 21, 2017 7:50 pm     Reply with quote

What pins are you using for UART2 on the 18F46K22 ?

What chip package does your board have for the 18F46K22 ?
maxrate



Joined: 01 Jan 2007
Posts: 38
Location: Mississauga, Ontario, Canada

View user's profile Send private message

PostPosted: Fri Apr 21, 2017 7:51 pm     Reply with quote

Shocked
I've determined what I've been doing wrong. When consulting the datasheet (http://ww1.microchip.com/downloads/en/DeviceDoc/40001412G.pdf) I had been referencing the wrong "pin summary" table. I was viewing the table on page 6 - I should have been viewing page 7. I have my PINs mixed up as a result. The 2nd UART on a 18F46K22 are available on PINs RD7/RD6, NOT RB7/RB6.

Thank you for all who have viewed my post. I feel better now Very Happy
maxrate



Joined: 01 Jan 2007
Posts: 38
Location: Mississauga, Ontario, Canada

View user's profile Send private message

PostPosted: Fri Apr 21, 2017 7:53 pm     Reply with quote

Hello PCM Programmer - I just posted same time you posted. You were spot on in asking what PINs. I've been at this on and off all day. Seems your original suggestion/reference about the datasheet for HS operation/crystal speed triggered a thought on my end here that I should re-check the datasheet. I'm glad I did. Thank you again.
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