ok well i tried a lot of combinations
1.but i am not convinced i am truly in sleep mode yet
2. when i trigger the interupt i go to the service routine but it wont go back to the main program
interupt services for interupt priority edge triggers - these seem to be working
as code is exicuted when the triggers occure
the code for " sleep Over "is working as it just turns off/ on the power to the regulator
but the standby power routines are not coming back to the main program
i am using DT routines for interupt support
the main code triggers on flags that send it to the "power_standby" routine which shuts down the ports , clears the required interupts and then sets the sleep mode
int1-3 all call the same interupts service routine that turns the ports back on , external power and run the routines with in it all ok when the triggers occure
BUT ........ from there it never returns to the main program
i have tried moving the sleep comand within the main program
with " if statement triggers " but with no luck so far - see example 2
it seem that when the trigger occures it services the the interupt and then not much more ,
what am i missing
cheers
sheldon
STANDBY POWER ROUTINE - this is called when the flags are met from the main program - its prepares the cpu power mode as low as can be done and then sets the interupts ready for triggering prior to the sleep mode being setCode:ASM INT_LIST macro ; IntSource , Label , Type, ResetFlag? INT_Handler TMR0_INT, _Timer0_Count , PBP, yes ; call Timer0_Count subroutine INT_Handler RBC_INT, _Rx_mode_IOC , PBP, yes ; Call Rx_mode_IOC subroutine for RF RX_mode INT_Handler RX2_INT, _Term_RX , PBP, yes ; Call Term_input for terminal char buffer INT_Handler INT0_INT, _Sleep_Over , PBP, Yes ; Call for INT0 trigger - when exit sleep mode to got sleep over = reset / startup - power button INT_Handler INT1_INT, _Standby_Over , PBP, Yes ; Call for INT1 trigger - when exit sleep mode to goto standby mode - ctrl button INT_Handler INT2_INT, _Standby_Over , PBP, Yes ; Call for INT2 trigger - when exit stand mode to goto standby mode - button b INT_Handler INT3_INT, _Standby_Over , PBP, Yes ; Call for INT3 trigger - when exit sleep mode to goto standby mode - button a endm INT_CREATE ; Creates the Interrupt Processor ENDASM
main segment of code that calls the standby routine when flags are correctCode:' =========== Set Standby Power routine ================== Standby_Power: ' routine to put the handswitch in standby mode waiting to send EXT_PWR = 1 ' External power off ( active low) TRISC = $FE ' make all ports inputs except portc.0 for ColA output TRISD = $F7 ' make all ports inputs except portd.3 for PWR_ON output TRISE = $FF PMD0 = $FF ' TURN OFF ALL PERIPHERALS ON CPU PMD2 = $FF col_a = 0 ' TURN ON COLA = 0 INTCON3.0= 0 INTCON3.1= 0 INTCON3.2= 0 ' CLEAR INT1-3 interupt flag prior to enable INTCON.1 = 0 ' CLEAR INT0 interupt flag prior to enable @ INT_ENABLE INT0_INT ; Enable INT0 interupt to allow wakeup from Sleep command - Triggered by PWR_SW , active high @ INT_ENABLE INT1_INT ; Enable INT1 interupt to allow wakeup from Sleep command - Triggered by ctrl key , active Low @ INT_ENABLE INT2_INT ; Enable INT2 interupt to allow wakeup from Sleep command - Triggered by B key , active Low @ INT_ENABLE INT3_INT ; Enable INT3 interupt to allow wakeup from Sleep command - Triggered by A key , active Low OSCCON.7 =0 ' clear IDLEN bit ready for sleep command @ sleep ; sleep command @ nop return ' ----------------------------------------------------------
example 1
Code:'----------- main program --------------- Main: if PWR_standby = 1 and Remote_conf_flag = 0 then gosub standby_power ' if power-standby set and remote conf is not then allow standby mode Goto main
tried this approche but the same results of it never returns to the main program , which is just moving the standby subrouine into the main " if "statement - no luck there
example 2
STANDBY OVER - INTERUPT SERVICE ROUTINE - This routine is called when the INt1-3 are triggered - it restores the ports to the correct setting and services to the cpuCode:'----------- main program --------------- Main: if PWR_standby = 1 and Remote_conf_flag = 0 then EXT_PWR = 1 ' External power off ( active low) TRISC = $FE ' make all ports inputs except portc.0 for ColA output TRISD = $F7 ' make all ports inputs except portd.3 for PWR_ON output TRISE = $FF PMD0 = $FF ' TURN OFF ALL PERIPHERALS ON CPU PMD2 = $FF col_a = 0 ' TURN ON COLA = 0 INTCON3.0= 0 INTCON3.1= 0 INTCON3.2= 0 ' CLEAR INT1-3 interupt flag prior to enable INTCON.1 = 0 ' CLEAR INT0 interupt flag prior to enable @ INT_ENABLE INT0_INT ; Enable INT0 interupt to allow wakeup from Sleep command - Triggered by PWR_SW , active high @ INT_ENABLE INT1_INT ; Enable INT1 interupt to allow wakeup from Sleep command - Triggered by ctrl key , active Low @ INT_ENABLE INT2_INT ; Enable INT2 interupt to allow wakeup from Sleep command - Triggered by B key , active Low @ INT_ENABLE INT3_INT ; Enable INT3 interupt to allow wakeup from Sleep command - Triggered by A key , active Low OSCCON.7 =0 ' clear IDLEN bit ready for sleep command @ sleep ; sleep command @ nop Goto main endif
it calls other rotuines that allows the keys to be activated faster than the normal scan rate would have from the timer0 settings
Code:' ---------------------------------------------------------- Standby_Over: ' RESTORE SETTINGS Standby_Return = 1 ' stop starup led seq write $0D,Standby_Return ' stop starup led seq when statup watchdog enabled INTCON3.0= 0 INTCON3.1= 0 INTCON3.2= 0 ' CLEAR INT1-3 interupt flag aftger trigger @ INT_DISABLE INT1_INT ; Enable INT1 interupt to allow wakeup from Sleep command - Triggered by ctrl key , active Low @ INT_DISABLE INT2_INT ; Enable INT2 interupt to allow wakeup from Sleep command - Triggered by B key , active Low @ INT_DISABLE INT3_INT ; Enable INT3 interupt to allow wakeup from Sleep command - Triggered by A key , active Low TRISC = %11010000 ' setup Port C input=1,output=0 for I/O pins TRISD = %00010000 ' setup Port D input=1,output=0 for I/O pins TRISE = %00001101 ' setup Port E input=1,output=0 for I/O pins EXT_PWR = 0 ' TURN ON EXTERNAL POWER gosub get_volts ' get the battery level gosub get_key_scan ' after standby-reset do a key scan to check on key being pressed T0Count5 = 400 ' set to 400 to all timer 0 to clear WDT flag set PWR_standby = 0 to allow main routine call standby agaiin after timeout @ INT_RETURN return




Bookmarks