Henrik,
It is using DHCP but the lease time is a couple days, so it's maintaining the same IP when it reconnects. The AP just drops it when it sits quiet for a while.
I ran a test and set up a regular loop running with a counter and periodically spitting the hserout and it worked fine.
The code I'm having an issue with is using Darrell Taylors interrupt setup. I don't think the interrupt is running as I can't get the light to flash.
Please see the two code samples below.
Code:'**************************************************************** '* Name : Heartbeat No Interrupt.PBP * '* : All Rights Reserved * '* Date : 10-29-15 * '* Version : 1.0 * '**************************************************************** #config __CONFIG _CONFIG1H, _OSCS_OFF_1H & _OSC_XT_1H __CONFIG _CONFIG2L, _BOR_ON_2L & _BORV_27_2L & _PWRT_ON_2L __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H __CONFIG _CONFIG3H, _CCP2MUX_OFF_3H __CONFIG _CONFIG4L, _LVP_OFF_4L #endconfig CLEAR DEFINE ADC_BITS 10 ' 10 Bit Resolution DEFINE ADC_CLOCK 3 ' Internal RC A/D Oscillator DEFINE ADC_SAMPLEUS 50 ' Delay before A/D Conversion DEFINE OSC 4 ' 4 MHz Internal Oscillator DEFINE HSER_RCSTA 90h ' Serial Input Enabled DEFINE HSER_TXSTA 24h ' Serial Output Enabled (High Speed) DEFINE HSER_BAUD 9600 ' Serial Baud Rate (9600 BPS) D CON 10 ' Divide by D (10 for 4MHz, 2 for 20MHz) LED1 VAR PortG.0 ' Test LED LED2 VAR PortG.4 ' Piezo Output Awake var byte ' variable for counting to keep unit alive on network Awake1 var byte ' variable for counting to keep unit alive on network ID1 var byte Buffer1 var byte Buffer2 var byte PortA = %00100000 ' PortA All Off PortB = %00000000 ' PortB All Off PortC = %00000000 ' PortC All Off PortD = %00000000 ' PortD All Off PortE = %00000000 ' PortE All Off PortF = %00000000 ' PortF All Off PortG = %00000000 ' PortG All Off TRISA = %00011111 ' Inputs = 1, Outputs = 0 TRISB = %11111111 ' Inputs = 1, Outputs = 0 TRISC = %10000010 ' Inputs = 1, Outputs = 0 TRISD = %11111111 ' Inputs = 1, Outputs = 0 TRISE = %11111111 ' Inputs = 1, Outputs = 0 TRISF = %11111111 ' Inputs = 1, Outputs = 0 TRISG = %00000000 ' Inputs = 1, Outputs = 0 RG(7-5) NA ADCON0 = %00000001 ' A/D Enabled, Channel 0 (AN0) ADCON1 = %00001110 ' AN0 Analog Input (Rest Digital I/O) ADCON2.7 = 1 ' Right Justify 10 Bit Word CMCON = %00000111 ' Both Comparators Disabled INTCON2.7 = 0 ' Turn ON PortB Pull-Ups T1CON = %00110100 ' 1:8 Prescale '**************************************************************** Awake = 0 Buffer2 = %11111111 'wifi heartbeat '*********************************************************************** Main: hserin 200,TimeOut,[dec2 ID1, skip 1, bin8 Buffer1] TimeOut: '*********************************************************************** ID1 = ID1 + 1 if ID1 = 99 then ID1 = 0 Awake = Awake + 1 if Awake > 50 then 'sends out Awake = 0 ' reset count toggle LED1 gosub Heartbeat endif goto Main Heartbeat: 'periodically send out current status to keep wifi alive Toggle LED2 ' toggle on Beep to see frequency Hserout ["y"] HSEROUT [dec2 ID1, " "] ' Decimal 2 Characters, Space HSEROUT [bin8 Buffer2] ' Binary 8 Characters, Space Hserout ["z"] returnThanks,Code:'**************************************************************** '* Name : Heartbeat Interrupt.PBP * '* : All Rights Reserved * '* Date : 10-29-15 * '* Version : 1.0 * '**************************************************************** #config __CONFIG _CONFIG1H, _OSCS_OFF_1H & _OSC_XT_1H __CONFIG _CONFIG2L, _BOR_ON_2L & _BORV_27_2L & _PWRT_ON_2L __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H __CONFIG _CONFIG3H, _CCP2MUX_OFF_3H __CONFIG _CONFIG4L, _LVP_OFF_4L #endconfig INCLUDE "DT_INTS-18.bas" ; Base Interrupt System INCLUDE "ReEnterPBP-18.bas" ; Include if using PBP interrupts INCLUDE "MODEDEFS.BAS" ' Include Shiftin/out modes 'INCLUDE "Elapsed_INT-18.bas" ; Elapsed Timer Routines 'GOSUB ResetTime ; Reset Time to 0d-00:00:00.00 'GOSUB StartTimer ; Start the Elapsed Timer CLEAR DEFINE ADC_BITS 10 ' 10 Bit Resolution DEFINE ADC_CLOCK 3 ' Internal RC A/D Oscillator DEFINE ADC_SAMPLEUS 50 ' Delay before A/D Conversion DEFINE OSC 4 ' 4 MHz Internal Oscillator DEFINE LOADER_USED 1 ' DEFINE HSER_RCSTA 90h ' Serial Input Enabled DEFINE HSER_TXSTA 24h ' Serial Output Enabled (High Speed) DEFINE HSER_BAUD 9600 ' Serial Baud Rate (9600 BPS) DEFINE HSER_CLOERR 1 ' automatic clear overrun error D CON 10 ' Divide by D (10 for 4MHz, 2 for 20MHz) ' '****************************************************************************** Awake var byte ' variable for counting to keep unit alive on network Awake1 var byte ' variable for counting to keep unit alive on network LED1 VAR PortG.0 ' Test LED LED2 VAR PortG.4 ' Piezo Output InBuffer1 VAR BYTE ' Input Buffer 1 InBuffer2 VAR BYTE ' Input Buffer 2 Buffer1 VAR BYTE ' Output Buffer 1 Buffer2 VAR BYTE ' Output Buffer 2 ID1 var byte ID2 var byte ID3 var byte '*********************************************************************** ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler RX_INT, _serialin, PBP, no endm INT_CREATE ; Creates the interrupt processor ENDASM T0CON = %10010010 ; T0 = 16-bit, Prescaler 8 @ INT_ENABLE RX_INT ; enable external (INT) interrupts '*********************************************************************** PortA = %00100000 ' PortA All Off (Rx Enabled/RF Switch = Receive) PortB = %00000000 ' PortB All Off PortC = %00000000 ' PortC All Off PortD = %00000000 ' PortD All Off PortE = %00000000 ' PortE All Off PortF = %00000000 ' PortF All Off PortG = %00000000 ' PortG All Off TRISA = %00011111 ' Inputs = 1, Outputs = 0 TRISB = %11111111 ' Inputs = 1, Outputs = 0 TRISC = %10000010 ' Inputs = 1, Outputs = 0 TRISD = %11111111 ' Inputs = 1, Outputs = 0 TRISE = %11111111 ' Inputs = 1, Outputs = 0 TRISF = %11111111 ' Inputs = 1, Outputs = 0 TRISG = %00000000 ' Inputs = 1, Outputs = 0 ADCON0 = %00000001 ' A/D Enabled, Channel 0 (AN0) ADCON1 = %00001111 ' AN0 Analog Input (Rest Digital I/O) ADCON2.7 = 1 ' Right Justify 10 Bit Word CMCON = %00000111 ' Both Comparators Disabled INTCON2.7 = 0 ' Turn ON PortB Pull-Ups T1CON = %00110100 ' 1:8 Prescale, T1OSCEN Off (524.288mS) '****************************************************************************** Awake = 0 Buffer2 = %11111111 'wifi heartbeat '*********************************************************************** Main: ID1 = ID1 + 1 if ID1 = 99 then ID1 = 0 Awake = Awake + 1 if Awake > 50 then 'sends out Awake = 0 ' reset count toggle LED1 'INTCON.6 = 0 'Interrupt 0=OFF, 1=ON gosub Heartbeat 'INTCON.6 = 1 'Interrupt 0=OFF, 1=ON endif goto Main Heartbeat: 'periodically send out current status to keep wifi alive Toggle LED2 ' toggle on Beep to see frequency Hserout ["y"] HSEROUT [dec2 ID1, " "] ' Decimal 2 Characters, Space HSEROUT [bin8 Buffer2] ' Binary 8 Characters, Space Hserout ["z"] return serialin: hserin [dec2 ID1, skip 1, bin8 Buffer1] 'hserin 2,NoSignal,[dec2 ID1, skip 1, bin8 Buffer1] @ INT_RETURN 'NoSignal: '@ INT_RETURN
Hylan




Bookmarks