Hi all,
I'm using interrupts on change on rising edge of one of four selected pins.
The code is sensing the rising edge. In fact the code execution stops when the rising edge is encountered.
However, the interrupt sub is not called and the code is freezed.
Here the relevant parts of the code:
#chip 18F45k42, 64#option explicit#config MCLRE = ON#startup InitPPS, 85'______________'USART#define USART_BAUD_RATE 9600#define USART_DELAY 5 ms#define USART_BLOCKING'Set pin USART directionsDir portC.7 INDir portC.6 OUT#define x_lim PortC.1#define y_lim PortC.2#define z_lim PortA.6#define Stop PortC.0Dir PortC.1 INDir PortC.2 INDir PortA.6 INDir PortC.0 INDim ind as ByteDim intpt0 As ByteDim intpt1 As Byte'=============Code======================ind=0intpt0=0intpt1=0'Interrupt settingsSET INTCON0.GIE ON 'enablingglobalinterruptSETPIE0.IOCIEON'enabling interrupt on ChangeSET IPR0.IOCIP ON 'sethighpriority'SET IOCxP.IOCxPy ON; interrupts su A6, C0, C1, C2 on rising edgeSET IOCAP.IOCAP6 ONSET IOCCP.IOCCP0 ONSET IOCCP.IOCCP1 ONSET IOCCP.IOCCP2 ONSET IOCAF6 OFFSET IOCCF0 OFFSET IOCCF1 OFFSET IOCCF2 OFF'INTONmain:ind=ind+1ifind>100thenHSerPrint" ind= "HSerPrintindHSerPrintCRLF1ind=0endifgotomainend'____________________________sub Interrupt: SET PIE0.IOCIE OFF if IOCAF.IOCAF6=1 or IOCCF.IOCCF1=1 or IOCCF.IOCCF2=1 then intpt0=1 end if if IOCCF.IOCCF0=1 then intpt1=1 end if HSerPrint " intpt0= " HSerPrint intpt0 HSerPrint " intpt1= " HSerPrint intpt1 SET PIE0.IOCIE OFF SET IOCAF6 OFF SET IOCCF0 OFF SET IOCCF1 OFF SET IOCCF2 OFFEnd SubSub InitPPS '//setsuppinsforUSARTUNLOCKPPS'Module: UART1 U1RXPPS = 0x0017 'RC7>RX1RC6PPS=0x0013'TX1 > RC6 LOCKPPS End Sub
I do not understand why the interrupt sub it is not called (as I believe, because intp0 and intp1 are never written and the code freezes).
I also used INTON command without success.
Thank you for any help.
Last edit: Anobium 2019-02-09
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Anobium,
thank you for your answer.
I apologize for my question.
In fact, at the beginning of the interrupt routine it was a "wait 40 s" instruction.
During my tests, I forgot that and I never waited 40 s to see if the code was fine. Accordingly, it seemed to me that the code never got the interrupt routine.
following your suggestion, I wached the first rows of the routine and I understood the mistake.
Finally, I cannot say why the "wait 40 s" instruction was not included in the code I submitted to the Forum.!!
I sincerely apologize for that.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all,
I'm using interrupts on change on rising edge of one of four selected pins.
The code is sensing the rising edge. In fact the code execution stops when the rising edge is encountered.
However, the interrupt sub is not called and the code is freezed.
Here the relevant parts of the code:
I do not understand why the interrupt sub it is not called (as I believe, because intp0 and intp1 are never written and the code freezes).
I also used INTON command without success.
Thank you for any help.
Last edit: Anobium 2019-02-09
Try removing the colon from the following line
sub Interrupt:Hi Anobium,
thank you for your answer.
I apologize for my question.
In fact, at the beginning of the interrupt routine it was a "wait 40 s" instruction.
During my tests, I forgot that and I never waited 40 s to see if the code was fine. Accordingly, it seemed to me that the code never got the interrupt routine.
following your suggestion, I wached the first rows of the routine and I understood the mistake.
Finally, I cannot say why the "wait 40 s" instruction was not included in the code I submitted to the Forum.!!
I sincerely apologize for that.