Herewith new more detail flow chart.
Please note:
1. There will be a Tamper switch Normally Open(Equipment removed state) connected to RA2. To start the MAIN loop of the PIC program, this must be monitored, first time it changes, switch(RA2-Input) goes LOW(0), GSM UNIT MUST BE POWERED UP through setting RA0-Output LOW(0) for 1s, after 1s return to HIGH(1).
The tamper switch must be continually monitored, if RA2 changes state, that state must be set to RA1 and kept in that state for 180s. Ignore state changes during 180s hold time.
2. If the GSM unit is ON, RA0 must never be activated, the GSM unit will pull RA3 LOW(0) if ON, so if RA3 = 0 do not trigger RA0.
3. Everytime RA0 is triggered, the 8-hour sleep cycle must restart. If nothing happens for 8-hours, then check RA3 != 0, then trigger RA0 for 1s and go back to sleep.
Questions:
I need to design and finalise the hardware urgently:
1. Do I need an external CLK crystal?
2. Do I need to use RB pins to interrupt sleep mode or is RA2 correct? (Tamper switch needs to interrupt and exit sleep mode)
Thank you.
---------- Post added at 15:15 ---------- Previous post was at 15:09 ----------
No, I do not want to do comms through USART.
The GSM module runs independantly from the PIC. PIC will trigger ON input on GSM which will wake up the GSM, it will perform some processes and shut itself down (OFF).
The PIC will monitor the Tamper Switch and run through an 8-hour cycle and then switch ON the GSM again.
The GSM consumes 1mA power in SLEEP, which is unacceptable, have to switch it OFF.
---------- Post added at 15:28 ---------- Previous post was at 15:15 ----------
This flowchart does not show the operation of the GSM module, it only shows the PIC operation and Digital IO interaction with GSM.