PIC18F452 Program stops on random number of interrupt

(instructions, reset, WDT, specifications...) PIC17Cxx, PIC18Fxxx

PIC18F452 Program stops on random number of interrupt

Postby Keno » Fri Nov 13, 2020 8:28 am

I made this program (and circuit) to learn a few basics about interrupts and how to implement them. In general, this program works, but not endlessly (as in infinite loop) as it was meant. For this project, I used two PIC18F452, and programmed them separately. I added. Both configuration bits header files are the same so I posted only one.

125373154_364147688027111_6119067638911343285_n.jpg (99.15 KiB) Viewed 195 times

File name ending with "_B" is program for first (bottom right) PIC. It outputs short duration pulses to turn on LED segments in a sequence. With first PIC I used ports B, C and D. Port E is used for outputting pulse, when the program of this PIC is over, which the second PIC "senses" as interrupt and starts its interrupt function, which basically continues turning on LEDs until the end of the row. As second PIC's (file name ending with "_A") interrupt function is triggered, it runs interrupt function, where ports B and D are used for outputting pulses for LEDs. When this program is over, it outputs a short duration pulse (as in case of ending the program of other PIC) on port E, which is then sensed as interrupt on the other PIC, and the whole program repeats itself.

As for ISR, I used INTCON register (INT0 on both PICs), both triggered at positive edge of pulse. As for the signal that is being outputted from one PIC to another to be sensed as interrupt on another, I simply used pin of port E ("LATE"). Program is started by pressing a button to Vdd, which enables one interrupt. Added 10k pull-down resistors on both interrupt inputs. Both PICs are built in the same way with same additional components. I used external Vdd (stabilized with 7805 voltage stabilizer). External crystal oscillator of 4 MHz on both. I also added RGB led to indicate the event, when each of interrupts happen (from PIC1 to PIC - green color, and red for other interrupt). I carefully wired everything together, trying to minimize length of all connections. I even soldered adapter for PICKit3 which connects directly to the breadboard.

Here is a video of operating program (hope it works - pass is 1234): https://vimeo.com/478800028

My suspicions are that maybe there should be some other register of interrupt control bytes low either high during the program.

*P.S. Might also be the XTAL frequency setting. I set it so low so I can turn on/off LEDs at such high rate. I could also specify that in delay functions but decided to define e.g. __delay_ms(500) which is 1 second at 4MHz so I could observe the behavior of the program at first stages of testing. Later I decreased XTAL frequency by large amount in order for LED to turn on/off quickly as they are doing right now.

(1.4 KiB) Downloaded 12 times

(1.31 KiB) Downloaded 12 times

(3.35 KiB) Downloaded 11 times
Posts: 6
Joined: Sat Nov 07, 2020 10:15 am
PIC experience: EE Student

Re: PIC18F452 Program stops on random number of interrupt

Postby Keno » Fri Nov 13, 2020 9:09 am

Found the problem. I added while(1){} in the main program. Whole program was constantly initializing and resetting without loop. Now it only only initializes one time per program.

* If anyone founds anything else regarding this program (regarding interrupts) that seems to be implemented improperly, please share your thoughts here.
Posts: 6
Joined: Sat Nov 07, 2020 10:15 am
PIC experience: EE Student

Return to 16-Bit Core

Who is online

Users browsing this forum: No registered users and 2 guests