Dave, I have adapted your 18F4550 code you included in your above post into a version that uses my schematic and an 18F2550. I have a protoboard configured to my schematic with the MiniSocket mounted on it. I have studied the AT+ Programmers Manual and I believe I understand all the coding and have it correct, but it wouldn't work. The only way I have to trouble shoot this is to embed WRITE to EEPROM statements at incremental locations to isolate where the problems are. I have discovered that in two places the code will not execute beyond certain statements even though this code compiles and assembles OK. If you look at my attached code (which is closely adapted from yours) you will see where the embedded WRITE statements bracket two statements that don't execute. One is a PAUSE 2000 statement that for the life of me I don't understand why it won't execute when uncommented. Can you see why?
The other is obviously telling me that the MiniSocket module is not resonding to the AT+I message and is therefore going to the BROKE label, which tells me that either the MiniSocket module is dead or my board level serial interface is not wired correctly.
I am hoping you might help me trouble shoot this by looking at this code and my attached interface and tell me where I have gone wrong. Would GREATLY appreciate it!
Code:
'<FL_PIC18F2550>'
DEFINE OSC 48    ' Using 8 MHz crystal
@ __CONFIG    _CONFIG1L, _PLLDIV_2_1L & _CPUDIV_OSC4_PLL6_1L & _USBDIV_2_1L
@ __CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H
@ __CONFIG    _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
@ __CONFIG    _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_OFF_3H
@ __CONFIG    _CONFIG4L, _LVP_OFF_4L &_XINST_OFF_4L
'#############################
    'ADCON1 = 001110          ' different A/D setup in temperature routine
    CNT      VAR BYTE
    CNT = 0
    temp     VAR BYTE
  WRITE 3,3      'EEPROM test to see if program executes to here..it does
    'ADC_TEMP VAR WORD        'not used in new temperature routine
    'S_TEMP   VAR BYTE        'not used in new temperature routine
    D_LAY    VAR BYTE
    ADR      VAR BYTE [9]     'array for IP address elements
    TX       VAR PORTC.6      'differnt ports used for WiFi module interface
    RX       VAR PORTC.7
    'X_TEMP   VAR BYTE        'not used in new temperature routine
WRITE 3,3  'EEPROM test to see if program executes to here..it does
    'PAUSE 2000   'FOR SOME REASON PROGRAM DOESN'T EXECUTE PAST HERE IF STATEMENT IS UNCOMMENTED
WRITE 4,4  'EEPROM test to see if program executes to here..it doesn't if above statement uncommented!
    'INTCON.5 = 1    'ENABLE TMR0  interrupt not used
    'T0CON = 000101
    'ON INTERRUPT GOTO TLOOP
'*****************SETUP FOR USING LM34 Temperature Sensor**************
    'DEFINE osc 8           ' Using a 16 MHz oscillator..already defined
    DEFINE ADC_BITS 10      ' Set A/D for 10-bit operation
    DEFINE ADC_CLOCK 5      ' Set A/D clock Fosc/16
    DEFINE ADC_SAMPLEUS 50  ' Set A/D sampling time @ 50 uS
    samples VAR WORD        ' Multiple A/D sample accumulator
    sample  VAR BYTE        ' Holds number of samples to take
    value   VAR WORD        ' Holds LM34 measured temperature value
BOOT:   'iCHIP SET UP
  'SEROUT2 PORTC.0,16468,["TEMP OUTSIDE ",DEC temp,$d,$a,$d ,$a] 'test not used
  PAUSE 500
  SEROUT2 TX,6,[ "AT+I",$d ,$a]
WRITE 5,5       'EEPROM test to see if program executes to here..it does
  SERIN2 RX ,6,2500,BROKE,[ WAIT("I/OK")]
WRITE 6,6   'EEPROM test to see if program executes to here..it doesn't!
     ' ABOVE TEST INDICATESInterface to iChip is NOT working!
  'SEROUT2 PORTC.0,16468 , [ "iChip OK",$d,$a ]  'test not used
  'SEROUT2 PORTC.0,16468 , [ "TEST_" , DEC3 CNT , 13 , 10 ]  'test not used
  SEROUT2 TX ,6 , [ "AT+iIPA?" , $d , $a ]
  SERIN2 RX ,6 , 2500 ,BOOT , [ DEC ADR[0] , DEC ADR[1] , DEC ADR[2] , DEC ADR[3] ]
  WRITE 10, ADR[0] ' Write the received IP address to EEPROM as a test
  WRITE 11, ADR[1]
  WRITE 12, ADR[2]
  WRITE 13, ADR[3]
  GOSUB DIP
  PAUSE 2000
  'SEROUT2 TX,6,["AT+iWLWM=1",$d,$a] ' Sets WEP enabled with 64bit key
  'SERIN2 RX ,6,2500,BROKE,[ WAIT("I/OK") ]
  'SEROUT2 TX,6,["AT+iWLKI=1",$d,$a] ' Sets the Wireless LAN transmission WEP-Key index
  'SERIN2 RX ,6,2500,BROKE,[ WAIT("I/OK") ]
  'SEROUT2 TX,6,["AT+iWLKn1=xxxxxxxxxx",$d,$a] ' Sets the Wireless LAN WEP key
  'SERIN2 RX ,6,2500,BROKE,[ WAIT("I/OK") ]
  SEROUT2 TX,6,["AT+iWLSI=Buckskin",$d,$a] ' Sets the destination Wireless LAN SSID
  SERIN2 RX ,6,2500,BROKE,[ WAIT("I/OK") ]
  SEROUT2 TX,6,["AT+iWWW",$d,$a]        ' Activates iChip's internal web server
  SERIN2 RX,6,1000,BOOT,[WAIT("I/(")]
  ;#############################
    EMAIL_SET:
        SEROUT2 TX,6,["AT+iSBJ:iChip ADC TEMPERATURE",$d,$a] 'Permanently sets Email header s Subject field
        SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
        SEROUT2 TX,6,["AT+iTOA:[email protected]",$d,$a]  'Permanently sets Email addressee
        SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
        SEROUT2 TX,6,["AT+ito:jellis00",$d,$a]      'Permanently sets Email header s =To:  description
        SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
        SEROUT2 TX,6,["AT+iREA:[email protected]",$d,$a] 'Permanently sets the RETURN EMAIL Address
        SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
        SEROUT2 TX,6,["AT+iFRM:iChip",$d,$a]        'Permanently sets Email header =From: description.
        SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
        SEROUT2 TX,6,["AT+iSMTP:mail.comcast.net",$d,$a]'Sets the SMTP Server Name or IP.
        SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
        SEROUT2 TX,6,["AT+iSMA=1",$d,$a]            'Permanently sets SMTP authentication method
        SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
        SEROUT2 TX,6,["AT+iSMP:Kevin111",$d,$a]       'Permanently sets authenticated SMTP login
        SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
        SEROUT2 TX,6,["AT+iSMU:[email protected]",$d,$a]'Permanently sets Authenticated SMTP login User Name.
        SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
   FTP:        'not using FTP but left this for timing
       CNT = CNT + 1
       GOSUB GET_T
       FOR D_LAY = 1 TO 120    ' 60 seconds delay
           PAUSE 500
       NEXT D_LAY
       IF CNT = 2 THEN EMAIL   ' Send EMAIL every 2 minutes
       IF CNT > 2 THEN CNT = 0 ' During testing set for two minute cycle
       WRITE 15, temp      'test of temperature reading
       GOTO BOOT
  END
  EMAIL:
        SEROUT2 TX,6,["AT+iEMA:",$d,$a]  'Defines a plain text e-mail body
        SEROUT2 TX,6,["HI, THIS IS FROM 206 N Veterans.",$d,$a]
        SEROUT2 TX,6,["SENT EVERY 2 minutes.",$d,$a]
        SEROUT2 TX,6,["THE TEMPERATURE IS.",$d,$a]
        SEROUT2 TX,6,[DEC temp," F Inside.",$d,$a]
        SEROUT2 TX,6,["GO TO:",$d,$a]
        SEROUT2 TX,6,["http://www.lodestarassoc.com/ichip/ichip.html",$d,$a]
        SEROUT2 TX,6,["FOR A ONE MINUTE UPDATE.",$d,$a]
        'After successfully sending the e-mail, IF the stay online flag (!) IS specified.
               SEROUT2 TX,6,[$d,$a,".",$d,$a]
               SERIN2 RX,6,[WAIT("I/ONLINE")]
        PAUSE 1000
        'SEROUT2 PORTC.0,16468,["EMAIL SENT ",$d,$a]  'test not used
        WRITE 5,$01       ' Write 1 to EEPROM as test if Email sent
        HIGH PORTC.5      ' blink green led as test to show email sent
        PAUSE 1000
        LOW PORTC.5
  GOTO BOOT
  DIP:
      'IF (!ADR[1]) AND )!ADR[1]) AND (!ADR[2]) AND (!ADR[3]) THEN
        HIGH PORTC.6      'blink red led as test if not connected
        PAUSE 1000
        LOW PORTC.6
      'ENDIF
      'SEROUT2 PORTC.0,16468,[" CONNECTED ",$d,$a] ' test not used
      'SEROUT2 PORTC.0,16468,["ADR - " ,DEC3 ADR[0],".",DEC3 ADR[1],".",DEC3 ADR[2],".",DEC3 ADR[3],$d,$a]
      PAUSE 1000
  RETURN
  BROKE:
        SEROUT2 PORTC.0,16468,["NOT WORKING",$d,$a] 'Commented out for now
        WRITE 16, "B"     'Record in EEPROM as test if Broke
        PAUSE 500
        GOTO BOOT
GET_T:        ' Subroutine to measure temperature from LM34
'===========
' This subroutine is an adaptation from below reference to 10-bit A/D
'****************************************************************
'*  Name    : LM34.BAS                                          *
'*  Author  : Bruce Reynolds                                    *
'*  Date    : 10/23/2001                                        *
'*  Version : 1.0                                               *
'*  Notes   :  8-bit A/D temperature conversion with National   *
'*          ;  LM34CAZ analog temperature sensor.               *
'*          :  See http://www.rentron.com/PicBasic/LM34.htm     *
'****************************************************************
    samples = 0             ' Clear samples accumulator on entry
    ' Setup registers for A/D input per Sec 21.0 of datasheet
    '1. Configure the A/D module:
      '  Configure analog pins, voltage reference AND I/O (ADCON1)
          ADCON1 = %00000011 'Vdd as ref; all analog except AN12 (RB0)
      '  SELECT A/D INPUT channel (ADCON0)
          ADCON0 = %001011000  'Set AN11 (PORTB.4) as A/D input but disabled
      '  SELECT A/D acquisition time & A/D conversion clock (ADCON2)
          ADCON2 = %10110101  'Right justified;TAD=16;A/D clock=Fosc/16
      '  Turn ON A/D module (ADCON0)
        ADCON0.0 = 1        'Enable the A/D module
    '2. Configure A/D INTERRUPT (IF desired):
        '  CLEAR ADIF BIT
        '  Set ADIE BIT
        '  Set GIE BIT
    '3. WAIT the required acquisition time (IF required).
        'PAUSE 250          ' Wait approximately 1/4 seconds per loop
    '4. Start conversion-Set GO/DONE BIT (ADCON0 register)
        ADCON0.1 = 1
    '5. WAIT FOR A/D conversion TO complete, by either:
        '  Polling FOR the GO/DONE BIT TO be cleared
            'OR
        '  Waiting FOR the A/D INTERRUPT
    FOR sample = 1 TO 20    ' Take 20 samples
        ADCIN 11, value      ' Read channel 11 into temp variable
        'PAUSE 2
        ' or use alternative manual method to read A/D input
            'WHILE ADCON0.1 : WEND
            '6. READ A/D Result registers (ADRESH:ADRESL);
                'CLEAR BIT ADIF, if required.
               'value.HIGHBYTE = ADRESH
               'value.LOWBYTE = ADRESL
         samples = samples + value ' Accumulate 20 samples
        '7. FOR NEXT conversion, go TO STEP 1 or STEP 2, as
            'required. The A/D conversion time per BIT IS
            'defined as TAD. A minimum WAIT of 3 TAD IS
            'required before the NEXT acquisition starts.
        PAUSE 250          ' Wait approximately 1/4 seconds per loop
    NEXT sample
    value = samples/20      ' Determine average of 20 measurements
    'ADC Math for 10-bit A/D when using Vdd as referenc
        'ADC Resolution = 4.99 V/1024 COUNT = 4.912109 mV/COUNT
        '=> LM34DZ OUTPUT voltage (mV) = 2 x COUNT
        'Temperature ( F) = LM34 OUTPUT voltage in mV/10
        '=> Temperature ( F) = 4.912109 x COUNT/10 = 0.4912109*COUNT
        ' Therefore temp = 0.4912109*Count or approx. = Count/2.036
    ' To avoid floating point math, multiply by 1000 and then DIV32
    value  = 1000 * value
    temp = DIV32 2036
    'temp = value
    samples = 0             ' Clear old sample accumulator for next cycle
    ADCON1 = 255            ' Go to all digital ops
  RETURN
  'DISABLE   'Interrupt not used
    'TLOOP:
    'INTCON.2=0:
    'TOGGLE PORTC.5
    'RESUME: ENABLE
Name:  PartialSchem.jpg
Views: 4059
Size:  105.3 KB