Greetings Richard,
that makes total sense, sorry for that.
Here is the code being used to test/troubleshoot the issue...
The sending PIC triggers COM pin high/low before sending the data.
The receiving PIC detects the COM trigger with IOC interrupt and starts listening.
This part of the code is working since it's detecting the trigger and starts listening.
The thing that is not working is the data reception correctly.
Send pic code
Code:'****************************************************************'* Name : 16F1508_Send.PBP * '* PORTA.2 CONNECTED TO PORTA.1 ON RECEIVING PIC * '**************************************************************** ' ;----[16F1508 Hardware Configuration]------------------------------------------- #IF __PROCESSOR__ = "16F1508" #DEFINE MCU_FOUND 1 #CONFIG cfg1 = _FOSC_INTOSC ; INTOSC oscillator: I/O function on CLKIN pin cfg1&= _WDTE_OFF ; WDT disabled cfg1&= _PWRTE_OFF ; PWRT disabled cfg1&= _MCLRE_OFF ; MCLR/VPP pin function is digital input cfg1&= _CP_OFF ; Program memory code protection is disabled cfg1&= _BOREN_OFF ; Brown-out Reset disabled cfg1&= _CLKOUTEN_OFF ; CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin cfg1&= _IESO_OFF ; Internal/External Switchover Mode is disabled cfg1&= _FCMEN_OFF ; Fail-Safe Clock Monitor is disabled __CONFIG _CONFIG1, cfg1 cfg2 = _WRT_OFF ; Write protection off cfg2&= _STVREN_OFF ; Stack Overflow or Underflow will not cause a Reset cfg2&= _BORV_LO ; Brown-out Reset Voltage (Vbor), low trip point selected. cfg2&= _LPBOR_OFF ; Low-Power BOR is disabled cfg2&= _LVP_OFF ; High-voltage on MCLR/VPP must be used for programming __CONFIG _CONFIG2, cfg2 #ENDCONFIG #ENDIF ;----[Verify Configs have been specified for Selected Processor]---------------- ; Note: Only include this routine once, after all #CONFIG blocks #IFNDEF MCU_FOUND #ERROR "No CONFIGs found for [" + __PROCESSOR__ +"]" # DEFINE OSC 16 ' Let PBP clock speed will be 16MHz OSCCON = %01111011 ' Use internal oscillator and set to 16MHz OPTION_REG.7 = 0 ' Enable individual control of weak pull-ups WPUA.0 = 0 ' Disable weak pull-up on RA0 WPUA.1 = 0 ' Disable weak pull-up on RA1 WPUA.2 = 0 ' Disable weak pull-up on RA2 WPUA.3 = 0 ' Disable weak pull-up on RA3 WPUA.4 = 1 ' Enable weak pull-up on RA4 WPUA.5 = 1 ' Enable weak pull-up on RA5 DACCON0.7 = 0 ' Disable DAC CM1CON0.7 = 0 ' Disable comparator 1 CM2CON0.7 = 0 ' Disable comparator 2 TRISA = %00000000 TRISB = %00000000 TRISC = %00000000 '***************************************************************************** INCLUDE "ALLDIGITAL.pbp" DEFINE SHOWDIGITAL 1 INCLUDE "modedefs.bas" DEFINE DEBUG_REG PORTA ' Set Debug pin port DEFINE DEBUG_BIT 2 ' Set Debug pin bit DEFINE DEBUG_BAUD 2400 ' Set Debug baud rate DEFINE DEBUG_MODE 0 ' Set Debug mode: 0 = true, 1 = inverted '***************************************************************************** 'PORTS & PINS COMMTX VAR PORTA.2 MESLED VAR PORTB.5 'MESSAGE LED PreAmble CON $A5 '***************************************************************************** INIT: PORTA=%00000000 PORTB=%00000000 PORTC=%00000000 GOTO START '***************************************************************************** START: HIGH INTLED HIGH COMMTX PAUSE 500 LOW COMMTX LOW INTLED PAUSE 200 HIGH MESLED debug PreAmble,$af,$c2,$b5,$ef,13,10 PAUSE 500 LOW MESLED PAUSE 4000 GOTO START '------------------------------------------------------------------------------
Receive pic code
Thanks for the helpCode:'****************************************************************'* Name : 16F1503_Receive.PBP * '* PORTA.1 CONNECTED TO PORTA.2 ON SENDING PIC * '**************************************************************** ' ;----[16F1503 Hardware Configuration]------------------------------------------- #IF __PROCESSOR__ = "16F1503" #DEFINE MCU_FOUND 1 #CONFIG cfg1 = _FOSC_INTOSC ; INTOSC oscillator: I/O function on CLKIN pin cfg1&= _WDTE_OFF ; WDT disabled cfg1&= _PWRTE_OFF ; PWRT disabled cfg1&= _MCLRE_OFF ; MCLR/VPP pin function is digital input cfg1&= _CP_OFF ; Program memory code protection is disabled cfg1&= _BOREN_OFF ; Brown-out Reset disabled cfg1&= _CLKOUTEN_OFF ; CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin __CONFIG _CONFIG1, cfg1 cfg2 = _WRT_OFF ; Write protection off cfg2&= _STVREN_OFF ; Stack Overflow or Underflow will not cause a Reset cfg2&= _BORV_LO ; Brown-out Reset Voltage (Vbor), low trip point selected. cfg2&= _LPBOR_OFF ; Low-Power BOR is disabled cfg2&= _LVP_OFF ; High-voltage on MCLR/VPP must be used for programming __CONFIG _CONFIG2, cfg2 #ENDCONFIG #ENDIF ;----[Verify Configs have been specified for Selected Processor]---------------- ; Note: Only include this routine once, after all #CONFIG blocks #IFNDEF MCU_FOUND #ERROR "No CONFIGs found for [" + __PROCESSOR__ +"]" #ENDIF '***************************************************************************** DEFINE OSC 16 ' Let PBP clock speed will be 16MHz OSCCON = %01111011 ' Use internal oscillator and set to 16MHz OPTION_REG.7 = 0 ' Enable individual control of weak pull-ups WPUA.0 = 0 ' Disable weak pull-up on RA0 WPUA.1 = 0 ' Disable weak pull-up on RA1 WPUA.2 = 0 ' Disable weak pull-up on RA2 WPUA.3 = 0 ' Disable weak pull-up on RA3 WPUA.4 = 0 ' Disable weak pull-up on RA4 WPUA.5 = 0 ' Disable weak pull-up on RA5 DACCON0.7 = 0 ' Disable DAC CM1CON0.7 = 0 ' Disable comparator 1 CM2CON0.7 = 0 ' Disable comparator 2 TRISA = %00001010 ' Set RA1-RA3 as inputs TRISC = %00000000 ' Set RC port as output '***************************************************************************** INCLUDE "ALLDIGITAL.pbp" DEFINE SHOWDIGITAL 1 INCLUDE "DT_INTS-14.bas" ' Base Interrupt System INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts INCLUDE "modedefs.bas" DEFINE DEBUG_REG PORTA ' Set Debug pin port DEFINE DEBUG_BIT 3 ' Set Debug pin bit DEFINE DEBUG_BAUD 2400 ' Set Debug baud rate DEFINE DEBUG_MODE 0 ' Set Debug mode: 0 = true, 1 = inverted DEFINE DEBUGIN_REG PORTA ' Set Debugin pin port DEFINE DEBUGIN_BIT 1 ' Set Debugin pin bit DEFINE DEBUGIN_BAUD 2400 ' Set Debugin baud rate (same as Debug baud) DEFINE DEBUGIN_MODE 0 ' Set Debugin mode: 0 = true, 1 = inverted '***************************************************************************** ;____[ For 12F/16F only - Interrupt Context save locations]_________________ ;-- Place a copy of these variables in your Main program ------------------- ;-- The compiler will tell you which lines to un-comment -- ;-- Do Not un-comment these lines -- ;--------------------------------------------------------------------------- ;wsave VAR BYTE $20 SYSTEM ' location for W if in bank0 ;wsave VAR BYTE $70 SYSTEM ' alternate save location for W ' if using $70, comment wsave1-3 ' --- IF any of these three lines cause an error ?? ------------------------ ' Comment them out to fix the problem ---- ' -- Which variables are needed, depends on the Chip you are using -- ;wsave1 VAR BYTE $A0 SYSTEM ' location for W if in bank1 ;wsave2 VAR BYTE $120 SYSTEM ' location for W if in bank2 ;wsave3 VAR BYTE $1A0 SYSTEM ' location for W if in bank3 ' -------------------------------------------------------------------------- 'https://www.picbasic.co.uk/forum/showthread.php/3251-Instant-Interrupts-Revisited/page7?highlight=DT%27s+instant+interrupts 'https://www.picbasic.co.uk/forum/showthread.php/3251-Instant-Interrupts-Revisited/page16?highlight=DT%27s+instant+interrupts 'Open the DT_INTS-14.bas file and comment out the wsave lines. 'The 675 doesn't have any usable RAM in banks 1,2 or 3 '***************************************************************************** INTCON.3=1 IOCAP.1=1 'POSITIVE EDGE @ A1 ON IOCAN=%0 'NEGATIVE EDGE OFF 'page 106 '***************************************************************************** '---[INT - interrupt handler]--------------------------------------------------- ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler IOC_INT, _IOCinterrupts, PBP, yes endm INT_CREATE ; Creates the interrupt processor ENDASM @ INT_ENABLE IOC_INT '***************************************************************************** 'PORTS & PINS INTLED VAR PORTC.3 'INTERRUPT LED MESLED VAR PORTC.4 'MESSAGE LED '***************************************************************************** DAT1 VAR BYTE ' DAT2 VAR BYTE ' DAT3 VAR BYTE ' CT VAR BYTE ' '***************************************************************************** INIT: PORTC=%000000 GOTO START '------------------------------------------------------------------------------ START: LOW INTLED LOW MESLED GOTO START '------------------------------------------------------------------------------ IOCinterrupts: @ INT_DISABLE IOC_INT HIGH INTLED PAUSE 500 DEBUGIN 1000,timeoutlabel,[WAIT($af),DAT1,DAT2,DAT3] PAUSE 200 pause 500 low INTLED PAUSE 500 IF DAT1=$c2 THEN GOTO PROGSEL ENDIF 'RETURN TO PROGRAM IOCAF=%0 @ INT_ENABLE IOC_INT @ INT_RETURN ;------------------------------------------------------------------------------- timeoutlabel: low INTLED HIGH MESLED debug DEC 99,DAT1,DAT2,DAT3,13,10 'Message confirming bad reception pause 1000 low MESLED 'RETURN TO PROGRAM IOCAF=%0 @ INT_ENABLE IOC_INT @ INT_RETURN ;------------------------------------------------------------------------------- PROGSEL debug DEC 09,DAT1,DAT2,DAT3,13,10 'Message confirming reception for ct=0 to 10 toggle INTLED toggle MESLED pause 500 next ct 'RETURN TO PROGRAM IOCAF=%0 @ INT_ENABLE IOC_INT @ INT_RETURN ;-------------------------------------------------------------------------------




Bookmarks