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".
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
"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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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 PinDEBUG_Write=TRUE'*******************************************************DimZaehlerAsByte'temp. ZählvariableDimLENZaehlerAsByte'TelegrammlängenzählerDimCheckZaehlerAsByte'ChecksummenzählerDimUIDZaehlerAsByte'Laufvariable für UID-AddressenDimZeitZaehlerAsByte'ZeitzählerDimTempVarAsByte'temp. VariableDimZeigerAsByte'temp. ZählvariableDimErrorFlagAsByte'FehlermerkerDimTagMerkerAsByte'temp. ZustandsmerkerDimKartAnzEEPAsByte'Anzahl der im EEPROM gespeicherten KartenDimMCARD(6)'7 Byte Array für (Master CARD-UID)DimDataBLOCK(6)'7 Byte Array für EEPROM-Daten (UID)DimBedingungAsByte'Temp. Bedingung oder Merker für nachfolgende AbfrageDimUID(6)'UID kann bis zu 7 Bytes lang seinDimUIDCheck(6)'Variable zur Ermittlung von neuer MasterCARDDimChecksumASByte'Variable für ChecksummeDIMhser_buffer(13)'Es können bis zu 13 Bytes von SL031 gesendet werden'Diese liegen von 0-12. Die 13. Stelle ist ein DummybyteDIMhserptr'Pointer for above buffer arrayDIMus_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 ***doloop'******************* SUB's****************************SubLeseEEPForUIDZaehler=0to255;eeprom_rd_byte(device_number,address,value)eeprom_rd_byte(eepDev,UIDZaehler,UID(UIDZaehler))HSerPrint(UIDZaehler)HSerPrint" "wait5msNextUIDZaehlerHSerPrintCRLFEndSubEnd
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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 PinDEBUG_Write=TRUE'*******************************************************DimZaehlerAsByte'temp. ZählvariableDimLENZaehlerAsByte'TelegrammlängenzählerDimCheckZaehlerAsByte'ChecksummenzählerDimUIDZaehlerAsByte'Laufvariable für UID-AddressenDimZeitZaehlerAsByte'ZeitzählerDimTempVarAsByte'temp. VariableDimZeigerAsByte'temp. ZählvariableDimErrorFlagAsByte'FehlermerkerDimTagMerkerAsByte'temp. ZustandsmerkerDimKartAnzEEPAsByte'Anzahl der im EEPROM gespeicherten KartenDimMCARD(6)'7 Byte Array für (Master CARD-UID)DimDataBLOCK(6)'7 Byte Array für EEPROM-Daten (UID)DimBedingungAsByte'Temp. Bedingung oder Merker für nachfolgende AbfrageDimUID(6)'UID kann bis zu 7 Bytes lang seinDimUIDCheck(6)'Variable zur Ermittlung von neuer MasterCARDDimChecksumASByte'Variable für ChecksummeDIMhser_buffer(13)'Es können bis zu 13 Bytes von SL031 gesendet werden'Diese liegen von 0-12. Die 13. Stelle ist ein DummybyteDIMhserptr'Pointer for above buffer arrayDIMus_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 ***doloop'******************* SUB's****************************SubLeseEEPForUIDZaehler=0to255;eeprom_rd_byte(device_number,address,value)tt(eepDev,UIDZaehler,UID(UIDZaehler))HSerPrint(UIDZaehler)HSerPrint" "//wait5msNextUIDZaehlerHSerPrintCRLFEndSubEndsubtt(iin,iiiin,outooutt)dimoouttooutt=1endsub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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".
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
Frank - we have just released the latest build of GCStudio - this does have the correct mega328pb.dat file.
Evan
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
The master DAT here has NO interrupt section.
Please post what you have.
"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
I meant that I thought the interupt section was missing in the DAT here.
Get the latest here - https://sourceforge.net/p/gcbasic/code/HEAD/tree/GCBASIC/trunk/chipdata/mega168pb.dat?format=raw
If you can use it and make sure it is good - then, I would be grateful.
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...
Just about to upload the latest build. I will post a URL very soon.
Latest patch build 1178 - apply all files to an existing installation.
https://sourceforge.net/projects/gcbasic/files/Release%20Candidates/Patches/gcb%40Syn.zip/download
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
What version of compiler are you using?
gcb 0.99.01
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
;Program compiled by Great Cow BASIC (0.99.01 2022-01-27 (Windows 64 bit) : Build 1073) for Microchip MPASM
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
"Ping me on google chat please" - Oh no - I have no Google account...
Skype; Yahoo; Whatsapp;
Choose one... :-) Send me a private message with contact info. :-)
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
Thank you very much! I had already feared that somewhere an array is described beyond the permissible field - I have simply overlooked here!
Frank
I was worried... I thought for a moment.. a bug! :-)