Menu

Wrong entry in "mega328pb.dat"

Frank
2022-09-16
2022-10-21
  • Frank

    Frank - 2022-09-16

    I don't know if it is the same in the current version, I am still working with version 0.98.070, in any case the entry for the DDRE register is wrong there.
    The file says "DDRE,14", but the correct value is "DDRE,13".

     
  • Anobium

    Anobium - 2022-09-16

    The 1169 16/09/2022 build has the correct DAT file.

    Frank - you are correct the master chipfile was out of sync. The mega328pb is a hand crafted DAT file and I had missed moving the correct DAT file to the master build.

    Thank you for reporting.

    Evan

     
  • Anobium

    Anobium - 2022-09-17

    Frank - we have just released the latest build of GCStudio - this does have the correct mega328pb.dat file.

    Evan

     
  • Frank

    Frank - 2022-10-13

    I just found another wrong entry:

    UsartRX1Ready:USART0_RX,36,RXCIE0,RXC0
    UsartTX1Ready:USART0_UDRE,38,UDRIE0,UDRE0
    UsartTX1Sent:USART0_TX,40,TXCIE0,TXC0
    ADCReady:ADC,42,ADIE,ADIF
    EEPROMReady:EE_READY,44,EERIE,
    Comp1Change:ANALOG_COMP,46,ACIE,ACI
    TWIReady:TWI,48,TWIE,TWINT
    SPMReady:SPM_Ready,50,SPMIE,
    Usart0Start:USART0_Start,52,SFDE,
    PinChange3:PCINT3,54,PCIE3,PCIF3
    UsartRX1Ready:USART1_RX,56,RXCIE1,RXC1
    UsartTX1Sent:USART1_TX,58,TXCIE1,TXC1
    UsartTX1Ready:USART1_UDRE,60,UDRIE1,UDRE1

    The second USART RX1 and TX1 should be called RX2 and TX2 - has this also been corrected yet?
    (I didn't get around to installing the new version yet...)

    Frank

     
  • Anobium

    Anobium - 2022-10-13

    The master DAT here has NO interrupt section.

    Please post what you have.

     
  • Frank

    Frank - 2022-10-14

    "The master DAT here has NO interrupt section." - what do you mean by this?

    This is only an excerpt from the DAT file. I need both USARTs for a project.

    USART0 (addressed as USART 1 in the program) worked, but not USART1 (which must be addressed as USART 2 in GCB).
    In the DAT file, however, the USART0 and the USART1 are assigned to the GCB USART 1. Only after I renamed the above bold RX1 and TX1 to RX2 and TX2, now also the second USART works.

    Frank

     
  • Frank

    Frank - 2022-10-14

    Can you give me a link to the current GCB? I just installed v0.99.01 and it also has the buggy 328pb.dat file...

     
    • Anobium

      Anobium - 2022-10-14

      Just about to upload the latest build. I will post a URL very soon.

       
  • Frank

    Frank - 2022-10-21

    Something still seems to be wrong.
    It seems that there is an overlap of the variable memory with the program memory when using "#include <i2ceeprom.h>".</i2ceeprom.h>

    The For-Next loop in "LeseEEP" runs endlessly and with this section of code only counts to 32, then starts again at 0 and never reaches 255.

    In the original program it counted to 74. Without "#include <i2ceeprom.h>" and without the call "eeprom_rd_byte(eepDev, UIDZaehler, UID(UIDZaehler))" the loop counts correctly to 255.</i2ceeprom.h>

    Is there still an error in the DAT file???

    Frank

    #chip MEGA328PB, 16
    #include <i2ceeprom.h>
    #OPTION Explicit                'All variables must first be declared!!!
    #define DEBUG_TRANS     PORTD.1    'TxD Pin for debugging
    #define DEBUG_Write     PORTD.2    'R#/W RS485 Pin
    DEBUG_Write=TRUE
    '*******************************************************
    Dim Zaehler           As Byte     'temp. Zählvariable
    Dim LENZaehler        As Byte     'Telegrammlängenzähler
    Dim CheckZaehler      As Byte     'Checksummenzähler
    Dim UIDZaehler        As Byte     'Laufvariable für UID-Addressen
    Dim ZeitZaehler       As Byte     'Zeitzähler
    Dim TempVar           As Byte     'temp. Variable
    Dim Zeiger            As Byte     'temp. Zählvariable
    Dim ErrorFlag         As Byte     'Fehlermerker
    Dim TagMerker         As Byte     'temp. Zustandsmerker
    Dim KartAnzEEP        As Byte     'Anzahl der im EEPROM gespeicherten Karten
    Dim MCARD(6)                      '7 Byte Array für (Master CARD-UID)
    Dim DataBLOCK(6)                  '7 Byte Array für EEPROM-Daten (UID)
    Dim Bedingung         As Byte     'Temp. Bedingung oder Merker für nachfolgende Abfrage
    Dim UID(6)                        'UID kann bis zu 7 Bytes lang sein
    Dim UIDCheck(6)                   'Variable zur Ermittlung von neuer MasterCARD
    Dim Checksum          AS Byte     'Variable für Checksumme
    
    DIM hser_buffer(13)               'Es können bis zu 13 Bytes von SL031 gesendet werden
                                      'Diese liegen von 0-12. Die 13. Stelle ist ein Dummybyte
    DIM hserptr                       'Pointer for above buffer array
    DIM us_cntr                       'Counter - Counts microseconds
    
    '*** USART settings for USART1 ***
    #define USART_BAUD_RATE 115200 '19200
    #define USART_TX_BLOCKING
    #define USART_DELAY OFF
    
    '*** Config I2C ***
    #define I2C_MODE Master
    #define I2C_DATA PORTC.4
    #define I2C_CLOCK PORTC.5
    #define I2C_DISABLE_INTERRUPTS ON
    
    '*** I2C_Adr_EEPROM ***
    #define eepDev 0xA0       'Basisadresse EEPROM 24C02C (256 Byte)
    
    LeseEEP
    
    '*** MAIN-LOOP ***
    do
    
    loop
    '******************* SUB's ****************************
    Sub LeseEEP 
      For UIDZaehler=0 to 255
        ;eeprom_rd_byte(device_number, address, value)
        eeprom_rd_byte(eepDev, UIDZaehler, UID(UIDZaehler))
        HSerPrint (UIDZaehler)
        HSerPrint " "
        wait 5 ms
      Next UIDZaehler
      HSerPrintCRLF
    End Sub
    
    End
    
     
  • Anobium

    Anobium - 2022-10-21

    What version of compiler are you using?

     
  • Frank

    Frank - 2022-10-21

    gcb 0.99.01

     
    • Anobium

      Anobium - 2022-10-21

      Sorry, post the top line of the ASM. Something like... I need the build number.

      ;Program compiled by Great Cow BASIC (1.00.00 Release Candidate 2022-10-19 (Windows 64 bit) : Build 1181) for Microchip AVR Assembler

       
  • Frank

    Frank - 2022-10-21

    ;Program compiled by Great Cow BASIC (0.99.01 2022-01-27 (Windows 64 bit) : Build 1073) for Microchip MPASM

     
  • Anobium

    Anobium - 2022-10-21

    Thanks. That tell you are on recent build.
    I just ran the code in a simulator for a MEGA328P. Serial runs to 32, then 255 and then halts.

    So, that tells this is not a 328PB issue. But, a more general issue.


    I have just tested reverting the FOR-NEXT loop to the legacy approach. Same issue. So, it is not the For-Next loop handler.

    I am looking at the ASM. Ping me on google chat please

     
  • Frank

    Frank - 2022-10-21

    "Ping me on google chat please" - Oh no - I have no Google account...

     
    • Anobium

      Anobium - 2022-10-21

      Skype; Yahoo; Whatsapp;

      Choose one... :-) Send me a private message with contact info. :-)

       
  • Anobium

    Anobium - 2022-10-21

    Found the root cause.

    I want to thank you for the clarity in your posts.

    The issue is using array element to get the result and then indexing the array beyond range of number of elements.

    UID(0..6)) but you address as UID(UIDZaehler where UID(UIDZaehler = 0..255)

    A quick change in your program should resolve.


    The program below is how I found it. The method TT() returns a know value so this ruled out all the EE/I2C routines.

    Evan

    #chip MEGA328P, 16
    #include <i2ceeprom.h>
    #OPTION Explicit                'All variables must first be declared!!!
    #define DEBUG_TRANS     PORTD.1    'TxD Pin for debugging
    #define DEBUG_Write     PORTD.2    'R#/W RS485 Pin
    DEBUG_Write=TRUE
    '*******************************************************
    Dim Zaehler           As Byte     'temp. Zählvariable
    Dim LENZaehler        As Byte     'Telegrammlängenzähler
    Dim CheckZaehler      As Byte     'Checksummenzähler
    Dim UIDZaehler        As Byte     'Laufvariable für UID-Addressen
    Dim ZeitZaehler       As Byte     'Zeitzähler
    Dim TempVar           As Byte     'temp. Variable
    Dim Zeiger            As Byte     'temp. Zählvariable
    Dim ErrorFlag         As Byte     'Fehlermerker
    Dim TagMerker         As Byte     'temp. Zustandsmerker
    Dim KartAnzEEP        As Byte     'Anzahl der im EEPROM gespeicherten Karten
    Dim MCARD(6)                      '7 Byte Array für (Master CARD-UID)
    Dim DataBLOCK(6)                  '7 Byte Array für EEPROM-Daten (UID)
    Dim Bedingung         As Byte     'Temp. Bedingung oder Merker für nachfolgende Abfrage
    Dim UID(6)                        'UID kann bis zu 7 Bytes lang sein
    Dim UIDCheck(6)                   'Variable zur Ermittlung von neuer MasterCARD
    Dim Checksum          AS Byte     'Variable für Checksumme
    
    DIM hser_buffer(13)               'Es können bis zu 13 Bytes von SL031 gesendet werden
                                      'Diese liegen von 0-12. Die 13. Stelle ist ein Dummybyte
    DIM hserptr                       'Pointer for above buffer array
    DIM us_cntr                       'Counter - Counts microseconds
    
    '*** USART settings for USART1 ***
    #define USART_BAUD_RATE 115200 '19200
    #define USART_TX_BLOCKING
    #define USART_DELAY OFF
    
    '*** Config I2C ***
    #define I2C_MODE Master
    #define I2C_DATA PORTC.4
    #define I2C_CLOCK PORTC.5
    #define I2C_DISABLE_INTERRUPTS ON
    
    '*** I2C_Adr_EEPROM ***
    #define eepDev 0xA0       'Basisadresse EEPROM 24C02C (256 Byte)
    
    LeseEEP
    
    '*** MAIN-LOOP ***
    do
    
    loop
    '******************* SUB's ****************************
    Sub LeseEEP 
      For UIDZaehler=0 to 255
        ;eeprom_rd_byte(device_number, address, value)
        tt(eepDev, UIDZaehler, UID(UIDZaehler))
        HSerPrint (UIDZaehler)
        HSerPrint " "
        // wait 5 ms
      Next UIDZaehler
      HSerPrintCRLF
    End Sub
    
    End
    
    
    sub tt ( iin, iiiin, out ooutt )
    dim ooutt
    ooutt = 1
    end sub
    
     
  • Frank

    Frank - 2022-10-21

    Thank you very much! I had already feared that somewhere an array is described beyond the permissible field - I have simply overlooked here!

    Frank

     
    • Anobium

      Anobium - 2022-10-21

      I was worried... I thought for a moment.. a bug! :-)

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.