 |
 |
| View previous topic :: View next topic |
| Author |
Message |
mtsoule
Joined: 19 Oct 2011 Posts: 33
|
| cannot get RDA2 interrupt to fire |
Posted: Mon Apr 06, 2026 8:26 am |
|
|
I feel I am overlooking something simple and need another set of eyes, I cannot get RDA2 interrupt to fire, I have seen all the previous posts but none has helped, I suspect it has something to do with my Pin Select since I can’t even get a kbhit() to work. My timer1 interrupt is working as expected but RDA2 is not, any help is appreciated.
main.h
| Code: |
//==========================================================================
// ifdef Section
//--------------------------------------------------------------------------
#ifndef _MAIN_H
#define _MAIN_H
//==========================================================================
// Include Section
//--------------------------------------------------------------------------
//#device ICD=TRUE
//////// Program memory: 65536x16 Data RAM: 8192 Stack: 127
//////// I/O: 44 Analog Pins: 43
//////// Data EEPROM: 1024
//////// C Scratch area: 500 ID Location: 200000
//////// Fuses: LP,XT,HS,NOEXTOSC,ECL,ECM,ECH,RSTOSC_HFINTRC_64MHZ
//////// Fuses: RSTOSC_EXT_PLL,RSTOSC_SOSC,RSTOSC_LFINTRC
//////// Fuses: RSTOSC_HFINTRC_1MHZ,RSTOSC_EXT,CLKOUT,NOCLKOUT,PRLOCK1WAY
//////// Fuses: NOPRLOCK1WAY,CKS,NOCKS,FCMEN,NOFCMEN,MCLR,NOMCLR,PUT_1MS
//////// Fuses: PUT_16MS,PUT_64MS,NOPUT,MVECEN,NOMVECEN,IVT1WAY,NOIVT1WAY
//////// Fuses: LPBOR,NOLPBOR,NOBROWNOUT,BROWNOUT_SW,BROWNOUT_NOSL,BROWNOUT
//////// Fuses: BORV28,BORV27,BORV24,BORV19,ZCDDIS,NOZCDDIS,PPS1WAY
//////// Fuses: NOPPS1WAY,STVREN,NOSTVREN,LVP,NOLVP,XINST,NOXINST,WDT64
//////// Fuses: WDT128,WDT256,WDT512,WDT1024,WDT2048,WDT4096,WDT8192
//////// Fuses: WDT16384,WDT32768,WDT65536,WDT131072,WDT262144,WDT524299
//////// Fuses: WDT1048576,WDT2097152,WDT4194304,WDT8388608,WDT32,WDTSW
//////// Fuses: NOWDT,WDT_SW,WDT_NOSL,WDT,WDTWIN_12%,WDTWIN_25%,WDTWIN_37%
//////// Fuses: WDTWIN_50%,WDTWIN_62%,WDTWIN_75%,WDTWIN_100%,WDTWIN_SW
//////// Fuses: WDTCLK_LFINTRC,WDTCLK_MFINTRC,WDTCLK_SOSC,WDTCLK_SW,BBSIZ32K
//////// Fuses: BBSIZ16K,BBSIZ8K,BBSIZ4K,BBSIZ2K,BBSIZ1K,BBSIZ512,BOOTBLOCK
//////// Fuses: NOBOOTBLOCK,SAF,NOSAF,DEBUG,NODEBUG,WRTB,NOWRTB,WRTC,NOWRTC
//////// Fuses: WRTD,NOWRTD,WRTSAF,NOWRTSAF,WRT,NOWRT,PROTECT,NOPROTECT
////////
#device PIC18F57Q43
#device PASS_STRINGS = IN_RAM
#FUSES RSTOSC_HFINTRC_64MHZ
#FUSES NOBROWNOUT
#use delay(internal = 64MHz)
//==========================================================================
// Define Section
//--------------------------------------------------------------------------
#define Success 1
#define Pass 1
#define Fail 0
#define Amb_Fail 3
#define Invalid_Input 2
#define True 1
#define False 0
// ***************************************************************************
// DEFINTION OF I/O PORTS
// ***************************************************************************
// ALL INPUT PINS ARE DEFINED USING THE PORT ADDRESS
// ALL OUTPUT PINS ARE DEFINED AS USING THE PORT LATCH ADDRESS
// ***** PORT 'A' *****
#define TRISA_RUN 0xFF // 1000 1011
#define PORTA_RUN 0xFF // PORTA OUTPUT INITIALIZATION DATA
// DEFINE PORT 'A' I/O FUNCTIONS
#define PORTA_0 pin_A0 //
#define PORTA_1 pin_A1 //
#define PORTA_2 pin_A2 //
#define PORTA_3 pin_A3 //
#define PORTA_4 pin_A4 //
#define PORTA_5 pin_A5 //
#define TXD3 pin_A6 // SIM7000 TXD
#define RXD3 pin_A7 // SIM7000 RXD
// ***** PORT 'B' *****
#define TRISB_RUN 0xFF // 1000 1011
#define PORTB_RUN 0xFF // PORTA OUTPUT INITIALIZATION DATA
// DEFINE PORT 'B' I/O FUNCTIONS
#define PORTB_0 pin_B0 //
#define PORTB_1 pin_B1 //
#define PORTB_2 pin_B2 //
#define PORTB_3 pin_B3 //
#define PORTB_4 pin_B5 //
#define PORTB_5 pin_B4 //
#define ICSPCK pin_B6 // In Circuit Serial Programming Clock
#define ICSPD pin_B7 // In Circuir Serial Programming Data
// ***** PORT 'C' *****
#define TRISC_RUN 0xFF // 1000 1011
#define PORTC_RUN 0xFF // PORTA OUTPUT INITIALIZATION DATA
// DEFINE PORT 'C' I/O FUNCTIONS
#define PORTC_0 pin_C0 //
#define PORTC_1 pin_C1 //
#define PORTC_2 pin_C2 // Flash CE
#define PORTC_3 pin_C3 // Flash SCLK
#define PORTC_4 pin_C4 // Flash Data In
#define PORTC_5 pin_C5 // Flash Data Out
#define TXD1 pin_C6 // Output - Dbug serial TX
#define RXD1 pin_C7 // Input - Dbug serial RX
// ***** PORT 'D' *****
#define TRISD_RUN 0x02 // 1000 1011
#define PORTD_RUN 0x02 // PORTA OUTPUT INITIALIZATION DATA
// DEFINE PORT 'D' I/O FUNCTIONS
#define TXD2 pin_D0 //O ESP8266 TXD
#define RXD2 pin_D1 //I ESP8266 RXD
#define PORTD_2 pin_D2 //O
#define PORTD_3 pin_D3 //O
#define PORTD_4 pin_D4 //O LCD Data 4
#define PORTD_5 pin_D5 //O LCD Data 5
#define PORTD_6 pin_D6 //O LCD Data 6
#define PORTD_7 pin_D7 //O LCD Data 7
// ***** PORT 'E' *****
#define TRISE_RUN 0x00 // 1000 1011
#define PORTE_RUN 0x00 // PORTA OUTPUT INITIALIZATION DATA
// DEFINE PORT 'E' I/O FUNCTIONS
#define LED_R pin_E0 // LCD Enable
#define LED_G pin_E1 // LCD RS
#define LED_B pin_E2 // LCD RW
#define VPP pin_E3 // Programming Voltage
// ***** PORT 'F' *****
#define TRISF_RUN 0xFF // 1000 1011
#define PORTF_RUN 0xFF // PORTA OUTPUT INITIALIZATION DATA
// DEFINE PORT 'F' I/O FUNCTIONS
#define PORTF_0 pin_F0 //
#define PORTF_1 pin_F1 //
#define PORTF_2 pin_F2 //
#define PORTF_3 pin_F3 //
#define PORTF_4 pin_F4 //
#define PORTF_5 pin_F5 //
#define PORTF_6 pin_F6 //
#define PORTF_7 pin_F7 //
#PIN_SELECT RX1=RXD1 //C7 pin 1
#PIN_SELECT TX1=TXD1 //C6 pin 48
#PIN_SELECT RX2=RXD2 //D1 pin 43
#PIN_SELECT TX2=TXD2 //D0 pin 42
#PIN_SELECT RX3=RXD3 //A7 pin 32
#PIN_SELECT TX3=TXD3 //A6 pin 33
#use delay(INT=32000000)
//#USE SPI (MASTER, DI=SDI1, DO=SDO1,CLK=SCK1,MODE=0, bits=8, STREAM=FLASH)
#use rs232(uart1,baud=115200,parity=N,xmit=TXD1,rcv=RXD1,bits=8,stream=Dbug)
#use rs232(uart2,baud=115200,parity=N,xmit=TXD2,rcv=RXD2,bits=8,stream=SIM)
#use rs232(uart3,baud=115200,parity=N,xmit=TXD3,rcv=RXD3,bits=8,stream=ESP)
//==========================================================================
// Function Prototypes Section
//--------------------------------------------------------------------------
// ***************************************************************************
// INTERNAL GLOBAL VARIABLES
// ***************************************************************************
//#define Dbug 0
// Default Defines
//#define True 1
//#define False 0
//Backlight Defines
#define Off 0
#define Red 1
#define Green 2
#define Blue 4
// EEPROM Locations
#define EE_SSID 0x0000
#define EE_PW 0x0040
#define EE_Amb_Delta 0x02
char New_Dbug_Char;
/*
int1 Dbug_Mode = True;
int t1_overflow;
int T1_OV_Flag;
int mike;
int Connection_Status;
char New_ESP_Char, New_Sim_Char;
int1 ESP_Char_Ready, SIM_Char_Ready, Dbug_Char_Ready;
char Device_SN[20]="48:3f:da:59:80:83";
char Get_WIFI_SSID[32] ="";
char Get_WIFI_PW[32]="";
int WIFI_Failed = False;
*/
unsigned int Current_Connection_Status;
#define ESP8266_Awake 0
#define ESP8266_Connected 1
#define ESP8266_Comm_Good 2
#define ESP8266_Disable 3
#define SIM_Awake 4
#define SIM_Connected 5
#define SIM_Comm_Good 6
#define SIM_Disable 7
// ***************************************************************************
#endif
|
main.c
| Code: |
#include "18F57Q43.h"
#include "main.h"
#include "SIM7000A.h"
#include "SIM7000A.c"
#include "isr.c"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void Setup_Config(void);
int main (int argc, char** argv)
{
Setup_Config();
while(True)
{
while (kbhit(SIM))
{
output_low(LED_R);
fprintf(sim,"uart2 output");//output_toggle(LED_R);
}
output_toggle(LED_B);
delay_ms(1000);
}
return (0);
}
//***************************************************************************
void Setup_Config(void)
{
setup_oscillator(OSC_HFINTRC_64MHZ);
SET_TRIS_A(TRISA_RUN);
SET_TRIS_B(TRISB_RUN);
SET_TRIS_C(TRISB_RUN);
SET_TRIS_D(TRISB_RUN);
SET_TRIS_E(TRISB_RUN);
SET_TRIS_F(TRISB_RUN);
setup_timer_1(T1_HFINTRC|T1_DIV_BY_1);// Timer1 interrupt
enable_interrupts(INT_TIMER1);
enable_interrupts(INT_RDA);
enable_interrupts(INT_RDA2);
enable_interrupts(INT_RDA3);
enable_interrupts(GLOBAL);
// setup_wdt(WDT_ON|WDT_16S);
// turn LEDS off
output_high(LED_R);
output_high(LED_G);
output_high(LED_B);
return;
}
|
isr.c
| Code: |
#include "main.h"
//#include "SIM7000A.h"
//--------------------------------------------------------------------------
int t1_overflow;
int T1_OV_Flag;
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
// The Timer One Inturrupt Service Routine
//
//
//--------------------------------------------------------------------------
#int_TIMER1
void T1_isr(void) // 32MHz Clock = 8MHz Instruction Cycle (0.125uS)
{ // 16 Bit Timer = 0.125uS * 65535 = 0.00819mS
t1_overflow++; //
//Second_Ctr_Temp++; // 8.19mS Inturrupt
//output_toggle(LED_G);
//Sleep_Pulse++;
//BT_Conn_Time_out++;
//output_toggle(PORTB_0);
//if (t1_overflow == 0x00) output_toggle(LED_B);
T1_OV_Flag =1; //
}
//--------------------------------------------------------------------------
// The UART interrupt, is connected to the Bluetooth receiving data
//
//
//--------------------------------------------------------------------------
// UART1 Int
#INT_RDA
void RDA_isr(void)
{
output_low(LED_G);
New_Dbug_Char=fgetc(Dbug);
}
// UART2 Int
#INT_RDA2
void RDA2_isr(void)
{
output_low(LED_R);
New_SIM_Char=fgetc(SIM);
}
// UART3 Int
#INT_RDA3
void RDA3_isr(void)
{
output_low(LED_B);
New_SIM_Char=fgetc(ESP);
}
|
|
|
 |
gaugeguy
Joined: 05 Apr 2011 Posts: 361
|
|
Posted: Mon Apr 06, 2026 11:38 am |
|
|
main does not accept any variables and does not return any. There is nothing to return to.
in the #use rs232 just specify the hardware UART port and do not specify the pins. That is what #pin_select is for. |
|
 |
mtsoule
Joined: 19 Oct 2011 Posts: 33
|
|
Posted: Wed Apr 08, 2026 11:17 am |
|
|
| gaugeguy, i tried your suggestion, still no joy... but thank you i just dont know why my RDA2 is not working.. |
|
 |
gaugeguy
Joined: 05 Apr 2011 Posts: 361
|
|
Posted: Wed Apr 08, 2026 12:08 pm |
|
|
| Where do you disable the analog functions for those pins? |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 20058
|
|
Posted: Wed Apr 08, 2026 10:59 pm |
|
|
You ned to look at table 21-1, The pins you are using do not support
UART2.  |
|
 |
|
|
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
|