ConnectOne and external EEPROM


+ Reply to Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default ConnectOne and external EEPROM

    In another thread dhouston is working on an Amicus18 shield for ConnectOne modules. These shields have a serial EEPROM on board to take some of the code load away from the MCU.

    For comparison a simple email routine is looked at. The code size went from 3,812 bytes used with out the EEPROM to 1,462 bytes used with an external EEPROM. The EEPROM needs to be loaded with data beforehand.

    The code displayed below was tested using an 18F6680 (not an Amicus) and a 24FC1025 EEPROM. This is my typical test bed.

    This is the code without an EEPROM, You may think it could be tightened up by placing the
    SERIN2 RX ,BAUD,2500,EMAIL_SET,[WAIT("I/OK")]
    in a sub routine. That line needs to be directly after the "AT+i" command, even a gosub will miss the "I/OK".
    Code:
    '  18F6680
    'BASIC CONNECT_ONE EMAIL
    'Program Memory Bytes Used:  3812
    '<FL_PIC18F6680>'
        DEFINE OSC 20
        @ __CONFIG    _CONFIG1H, _OSC_HS_1H
        @ __CONFIG    _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H
        @ __CONFIG    _CONFIG4L, _LVP_OFF_4L
    
        BAUD    CON 16572  '4800 INVERTED, PC
        'BAUD    CON 16390  '38400 INVERTED, PC
        TX       VAR PORTB.0
        RX       VAR PORTB.3
    
        BOOT:
        SEROUT2 TX,BAUD,[ "AT+I",$d ,$a]
        SEROUT2 TX,BAUD,["AT+iWWW",$d,$a]
        SERIN2 RX,BAUD,1000,BOOT,[WAIT("I/(")]
    
        EMAIL_SET:
        SEROUT2 TX,BAUD,["AT+iSBJ:MAC_ETHERNET",$d,$a]
        SERIN2 RX ,BAUD,2500,EMAIL_SET,[WAIT("I/OK")]
        SEROUT2 TX,BAUD,["AT+iTOA:[email protected]",$d,$a]
        SERIN2 RX ,BAUD,2500,EMAIL_SET,[WAIT("I/OK")]
        SEROUT2 TX,BAUD,["AT+ito:MACKRACKIT",$d,$a]
        SERIN2 RX ,BAUD,2500,EMAIL_SET,[WAIT("I/OK")]
        SEROUT2 TX,BAUD,["AT+iREA:[email protected]",$d,$a]
        SERIN2 RX ,BAUD,2500,EMAIL_SET,[WAIT("I/OK")]
        SEROUT2 TX,BAUD,["AT+iFRM:MAC_ETH",$d,$a]
        SERIN2 RX ,BAUD,2500,EMAIL_SET,[WAIT("I/OK")]
        SEROUT2 TX,BAUD,["AT+iSMTP:mail.XYZ.com",$d,$a]
        SERIN2 RX ,BAUD,2500,EMAIL_SET,[WAIT("I/OK")]
        SEROUT2 TX,BAUD,["AT+iSMA=1",$d,$a]
        SERIN2 RX ,BAUD,2500,EMAIL_SET,[WAIT("I/OK")]
        SEROUT2 TX,BAUD,["AT+iSMP:PASSWORD",$d,$a]
        SERIN2 RX ,BAUD,2500,EMAIL_SET,[WAIT("I/OK")]
        SEROUT2 TX,BAUD,["AT+iSMU:[email protected]",$d,$a]
        SERIN2 RX ,BAUD,2500,EMAIL_SET,[WAIT("I/OK")]
        
        EMAIL_SEND:
        SEROUT2 TX,BAUD,["AT+iEMA:",$d,$a]
        SEROUT2 TX,BAUD,["HI, THIS IS FROM MAC_ETH",$d,$a]
        SEROUT2 TX,BAUD,["SENT EVERY HOUR.",$d,$a]
        SEROUT2 TX,BAUD,["THE TEMPERATURE IS.",$d,$a]
        SEROUT2 TX,BAUD,["XX F IN THE SHOP.",$d,$a]
        SEROUT2 TX,BAUD,["GO TO:",$d,$a]
        SEROUT2 TX,BAUD,["http://mackrackit.com/mac/ichip/ichipw.py",$d,$a]
        SEROUT2 TX,BAUD,["FOR A ONE MINUTE UPDATE.",$d,$a]
        SEROUT2 TX,BAUD,[$d,$a,".",$d,$a]
        SERIN2 RX ,BAUD,60000,BOOT,[WAIT("I/ONLINE")]
        PAUSE 1000
        GOTO BOOT
    Now for the EEPROM loading code. This loads the EEPROM with the "AT+i" strings.
    Code:
    '  18F6680  24FC1025
    'LOAD EXTERNAL EEPROM WITH COMMAND STRINGS
    'Program Memory Bytes Used:  3564
    '<FL_PIC18F6680>'
        DEFINE OSC 20
        @ __CONFIG    _CONFIG1H, _OSC_HS_1H
        @ __CONFIG    _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H
        @ __CONFIG    _CONFIG4L, _LVP_OFF_4L
    
        DPIN    VAR PORTB.2    'I2C DATA PIN
        CPIN    VAR PORTB.1    'I2C CLOCK PIN
        ADDR    VAR WORD
        B0      VAR BYTE
        B1      VAR BYTE
        DATO    VAR BYTE
        TEXT_   VAR BYTE[45]
    
        'BUILD SOME TEXT
        'FOR EMAIL_SET
        'ES_1  :   ADDR = 1  : DATO = 22
        FOR B0 = 0 TO 21
        LOOKUP B0,["AT+iSBJ:MAC_ETHERNET",$d,$a],B1
        TEXT_(B0) = B1
        NEXT B0
        ADDR = 1
        I2CWRITE DPIN,CPIN,$A0,ADDR,[STR TEXT_\22]
        PAUSE 100
    
        'ES_2  :  ADDR = 23   : DATO = 21
        FOR B0 = 0 TO 20
        LOOKUP B0,["AT+iTOA:[email protected]",$d,$a],B1
        TEXT_(B0) = B1
        NEXT B0
        ADDR = 23
        I2CWRITE DPIN,CPIN,$A0,ADDR,[STR TEXT_\21]
        PAUSE 100
    
        'ES_3  : ADDR = 43    : DATO = 19
        FOR B0 = 0 TO 18
        LOOKUP B0,["AT+ito:MACKRACKIT",$d,$a],B1
        TEXT_(B0) = B1
        NEXT B0
        ADDR = 44
        I2CWRITE DPIN,CPIN,$A0,ADDR,[STR TEXT_\19]
        PAUSE 100
    
        'ES_4   :  ADDR = 65   : DATO = 21
        FOR B0 = 0 TO 20
        LOOKUP B0,["AT+iREA:[email protected]",$d,$a],B1
        TEXT_(B0) = B1
        NEXT B0
        ADDR = 65
        I2CWRITE DPIN,CPIN,$A0,ADDR,[STR TEXT_\21]
        PAUSE 100
    
        'ES_5   :  ADDR = 86   : DATO = 17
        FOR B0 = 0 TO 16
        LOOKUP B0,["AT+iFRM:MAC_ETH",$d,$a],B1
        TEXT_(B0) = B1
        NEXT B0
        ADDR = 86
        I2CWRITE DPIN,CPIN,$A0,ADDR,[STR TEXT_\17]
        PAUSE 100
    
        'ES_6  :  ADDR = 103   : DATO = 23
        FOR B0 = 0 TO 22
        LOOKUP B0,["AT+iSMTP:mail.XYZ.com",$d,$a],B1
        TEXT_(B0) = B1
        NEXT B0
        ADDR = 103
        I2CWRITE DPIN,CPIN,$A0,ADDR,[STR TEXT_\23]
        PAUSE 100
    
        'ES_7  :  ADDR = 128    : DATO = 11
        FOR B0 = 0 TO 10
        LOOKUP B0,["AT+iSMA=1",$d,$a],B1
        TEXT_(B0) = B1
        NEXT B0
        ADDR = 128
        I2CWRITE DPIN,CPIN,$A0,ADDR,[STR TEXT_\11]
        PAUSE 100
    
        'ES_8  :  ADDR =  139   : DATO = 18
        FOR B0 = 0 TO 17
        LOOKUP B0,["AT+iSMP:PASSWORD",$d,$a],B1
        TEXT_(B0) = B1
        NEXT B0
        ADDR = 139
        I2CWRITE DPIN,CPIN,$A0,ADDR,[STR TEXT_\18]
        PAUSE 100
    
        'ES_9  :  ADDR = 157    : DATO = 21
        FOR B0 = 0 TO 20
        LOOKUP B0,["AT+iSMU:[email protected]",$d,$a],B1
        TEXT_(B0) = B1
        NEXT B0
        ADDR = 157
        I2CWRITE DPIN,CPIN,$A0,ADDR,[STR TEXT_\21]
        PAUSE 100
    
        '#####################################
        'BUILD SOME TEXT
        'FOR EMAIL_SEND
        'ESX_1  :   ADDR = 178   : DATO = 10
        FOR B0 = 0 TO 9
        LOOKUP B0,["AT+iEMA:",$d,$a],B1
        TEXT_(B0) = B1
        NEXT B0
        ADDR = 178
        I2CWRITE DPIN,CPIN,$A0,ADDR,[STR TEXT_\10]
        PAUSE 100
    
        'ESX_2  :  ADDR = 188     : DATO = 26
        FOR B0 = 0 TO 25
        LOOKUP B0,["HI, THIS IS FROM MAC_ETH",$d,$a],B1
        TEXT_(B0) = B1
        NEXT B0
        ADDR = 188
        I2CWRITE DPIN,CPIN,$A0,ADDR,[STR TEXT_\26]
        PAUSE 100
    
        'ESX_3 :  ADDR = 214     : DATO = 18
        FOR B0 = 0 TO 17
        LOOKUP B0,["SENT EVERY HOUR.",$d,$a],B1
        TEXT_(B0) = B1
        NEXT B0
        ADDR = 214
        I2CWRITE DPIN,CPIN,$A0,ADDR,[STR TEXT_\18]
        PAUSE 100
    
        'ESX_4  :   ADDR = 232    : DATO = 21
        FOR B0 = 0 TO 20
        LOOKUP B0,["THE TEMPERATURE IS.",$d,$a],B1
        TEXT_(B0) = B1
        NEXT B0
        ADDR = 232
        I2CWRITE DPIN,CPIN,$A0,ADDR,[STR TEXT_\21]
        PAUSE 100
    
        'ESX_5  :   ADDR = 260    : DATO = 19
        FOR B0 = 0 TO 18
        LOOKUP B0,["XX F IN THE SHOP.",$d,$a],B1
        TEXT_(B0) = B1
        NEXT B0
        ADDR = 260
        I2CWRITE DPIN,CPIN,$A0,ADDR,[STR TEXT_\19]
        PAUSE 100
    
        'ESX_6  :  ADDR = 279     : DATO = 8
        FOR B0 = 0 TO 7
        LOOKUP B0,["GO TO:",$d,$a],B1
        TEXT_(B0) = B1
        NEXT B0
        ADDR = 279
        I2CWRITE DPIN,CPIN,$A0,ADDR,[STR TEXT_\8]
        PAUSE 100
    
        'ESX_7  :  ADDR = 287     : DATO = 43
        FOR B0 = 0 TO 42
        LOOKUP B0,["http://mackrackit.com/mac/ichip/ichipw.py",$d,$a],B1
        TEXT_(B0) = B1
        NEXT B0
        ADDR = 287
        I2CWRITE DPIN,CPIN,$A0,ADDR,[STR TEXT_\43]
        PAUSE 100
    
        'ESX_8  :  ADDR =  330     : DATO = 26
        FOR B0 = 0 TO 25
        LOOKUP B0,["FOR A ONE MINUTE UPDATE.",$d,$a],B1
        TEXT_(B0) = B1
        NEXT B0
        ADDR = 330
        I2CWRITE DPIN,CPIN,$A0,ADDR,[STR TEXT_\26]
        PAUSE 100
    
        'ESX_9  :  ADDR = 356      : DATO = 5
        FOR B0 = 0 TO 4
        LOOKUP B0,[$d,$a,".",$d,$a],B1
        TEXT_(B0) = B1
        NEXT B0
        ADDR = 356
        I2CWRITE DPIN,CPIN,$A0,ADDR,[STR TEXT_\5]
        PAUSE 100
    
        END
    The code to work the ConnectOne module with the aid of an external EEPROM.
    Code:
    '  18F6680  24FC1025
    'EEPROM DRIVEN CONNECT_ONE EMAIL
    'Program Memory Bytes Used:  1462
    '<FL_PIC18F6680>'
        DEFINE OSC 20
        @ __CONFIG    _CONFIG1H, _OSC_HS_1H
        @ __CONFIG    _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H
        @ __CONFIG    _CONFIG4L, _LVP_OFF_4L
    
        BAUD    CON 16572  '4800 INVERTED, PC
       ' BAUD    CON 16390  '38400 INVERTED, PC
        TX       VAR PORTB.0
        RX       VAR PORTB.3
        DPIN    VAR PORTB.2    'I2C DATA PIN
        CPIN    VAR PORTB.1    'I2C CLOCK PIN
        ADDR    VAR WORD
        DATI    VAR BYTE[45]
        DATO    VAR WORD
        B0      VAR BYTE
        B1      VAR BYTE
        TEXT_   VAR BYTE[45]
    
        BOOT:
        SEROUT2 TX,BAUD,[$d,$a]
        SEROUT2 TX,BAUD,[$d,$a]
        SEROUT2 TX,BAUD,[ "AT+I",$d ,$a]
        SEROUT2 TX,BAUD,["AT+iWWW",$d,$a]
        SERIN2  RX,BAUD,1000,BOOT,[WAIT("I/(")]
       
    
        EMAIL_SET:
        ES_1 : ADDR = 1   : DATO = 22
        GOSUB TEXT_1
        ES_2 : ADDR = 23  : DATO = 21
        GOSUB TEXT_1
        ES_3 : ADDR = 44  : DATO = 19
        GOSUB TEXT_1
        ES_4 : ADDR = 65  : DATO = 21
        GOSUB TEXT_1
        ES_5 : ADDR = 86  : DATO = 17
        GOSUB TEXT_1
        ES_6 : ADDR = 103 : DATO = 23
        GOSUB TEXT_1
        ES_7 : ADDR = 128 : DATO = 11
        GOSUB TEXT_1
        ES_8 : ADDR = 139 : DATO = 18
        GOSUB TEXT_1
        ES_9 : ADDR = 157 : DATO = 21
        GOSUB TEXT_1
    
        EMAIL_SEND:
        ESX_1 : ADDR = 178 : DATO = 10
        GOSUB TEXT_2
        ESX_2 : ADDR = 188 : DATO = 26
        GOSUB TEXT_2
        ESX_3 : ADDR = 214 : DATO = 18
        GOSUB TEXT_2
        ESX_4 : ADDR = 232 : DATO = 21
        GOSUB TEXT_2
        ESX_5 : ADDR = 260 : DATO = 19
        GOSUB TEXT_2
        ESX_6 : ADDR = 279 : DATO = 8
        GOSUB TEXT_2
        ESX_7 : ADDR = 287 : DATO = 43
        GOSUB TEXT_2
        ESX_8 : ADDR = 330 : DATO = 26
        GOSUB TEXT_2
        ESX_9 : ADDR = 356 : DATO = 5
        GOSUB TEXT_2
    
        GOTO BOOT
    
        TEXT_1:
        I2CREAD DPIN,CPIN,$A0,ADDR,[STR DATI\DATO]
        PAUSE 10
        SEROUT2 TX, BAUD, [STR DATI\DATO]
        SERIN2  RX ,BAUD,2500,EMAIL_SET,[WAIT("I/OK")]
        PAUSE 1000
        RETURN
    
        TEXT_2:
        I2CREAD DPIN,CPIN,$A0,ADDR,[STR DATI\DATO]
        PAUSE 10
        SEROUT2 TX, BAUD, [STR DATI\DATO]
        PAUSE 1000
        RETURN
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Dec 2005
    Posts
    1,073

    Default Re: ConnectOne and external EEPROM

    How much EEPROM memory for your example?

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: ConnectOne and external EEPROM

    361 bytes. And that was a small example...
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Dec 2005
    Posts
    1,073

    Default Re: ConnectOne and external EEPROM

    Quote Originally Posted by mackrackit View Post
    361 bytes. And that was a small example...
    That's a pretty good trade-off; 361 bytes of EEPROM saving 2350 bytes of program space. I2C EEPROM is inexpensive even for 128KB. I haven't analyzed your code but suspect you could save even more by wasting some EEPROM - using fixed length records and accessing them sequentially.

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: ConnectOne and external EEPROM

    I thought about that but was not sure how the Connect One would like it. Being a little short on time I just did what I knew would work for the sample.

    There is always room for improvement.
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Dec 2005
    Posts
    1,073

    Default Re: ConnectOne and external EEPROM

    Perhaps, store a length byte at the start of the strings?

    But, as is, I think the EEPROM achieves our goal of reducing the PBP code burden. Others might have even better ideas.
    Last edited by dhouston; - 22nd June 2011 at 22:47.

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: ConnectOne and external EEPROM

    Perhaps, store a length byte at the start of the strings?
    It would be cool if the I2C command had "WAIT"...
    Dave
    Always wear safety glasses while programming.

  8. #8
    Join Date
    Dec 2005
    Posts
    1,073

    Default Re: ConnectOne and external EEPROM

    Quote Originally Posted by mackrackit View Post
    It would be cool if the I2C command had "WAIT"...
    Maybe Darrel can give you a register or something where you can stick WAIT.

  9. #9
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: ConnectOne and external EEPROM

    Or a nice small ASM routine to parse...
    Dave
    Always wear safety glasses while programming.

  10. #10
    Join Date
    Dec 2005
    Posts
    1,073

    Default Re: ConnectOne and external EEPROM

    Bruce can probably provide an ASM routine. He's welcome to the Gerbers for both shields if he wants them.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts