Dr_Doggy
Well-Known Member
for those who have been following me you will be happy to hear that I got my code switched from cow to c, and the cube is running great, so the only sub left to write is my RXSERIAL which as it sound reads the serial port; and writes it to my EXTERNAL EEPROM, \
however i have found a few walls that i cant seem to get around:
a) first and farmost, I need a input buffer to write the 252 byte serial data to, to hold the info durring the rx, while it waits for processing. initally i declared the array as DIN1[]; to which i found no error but found that the stack was overflowing and reading from somewhere else altogether, so then i changed DIN[253], however complier now gives me an error 1300; stack frame to large, so doing resarch i cleaned up all my unused declarations and changed all my int's to unsigned chars(that s all i need anyway), with that i was able to get my stack size up to 120, from 60 or 80, I also read a trick that you can use pointers or something, but i'd like to avoid that if i can since they seem a little confusing, PLUS during my reading everyone who was having large buffer issues were using much larger arrays, and cow didnt have this problem, so i am surprised that i am now, im sure its something simple im missing.?
THE 18f4620 should be able to handle this....
b) i borrowed the following code from another thread here, and it seems to work ok, but it causes me grief if i use it in this loop, where the variable CNT gets set and stuck at 0 after the second or third cycle(all that i can see is that maybe: EECON2 = 0xaa; <---arnt those supposta be capital a's)
for (CNT=1;CNT<80;CNT++) {WriteEEPROM (CNT,10);}
unsigned char ReadEEPROM(unsigned char address){
EECON1=0; //ensure CFGS=0 and EEPGD=0
EEADR = address;
EECON1bits.RD = 1;
return(EEDATA);
}
void WriteEEPROM(unsigned char address,unsigned char data){
char SaveInt;
SaveInt=INTCON; //save interrupt status
EECON1=0; //ensure CFGS=0 and EEPGD=0
EECON1bits.WREN = 1; //enable write to EEPROM
EEADR = address; //setup Address
EEDATA = data; //and data
INTCONbits.GIE=0; //No interrupts
EECON2 = 0x55; //required sequence #1
EECON2 = 0xaa; //#2
EECON1bits.WR = 1; //#3 = actual write
INTCON=SaveInt; //restore interrupts
while(!PIR2bits.EEIF); //wait until finished
EECON1bits.WREN = 0; //disable write to EEPROM
}
c) since im here, im also wondering about assembly, i wanted to avoid it all together but i never knew how close to it i was anyway, reading the datasheets im seeing the similarities but maybe there is a SIMPLE tutorial that guides me through all that garble?
however i have found a few walls that i cant seem to get around:
a) first and farmost, I need a input buffer to write the 252 byte serial data to, to hold the info durring the rx, while it waits for processing. initally i declared the array as DIN1[]; to which i found no error but found that the stack was overflowing and reading from somewhere else altogether, so then i changed DIN[253], however complier now gives me an error 1300; stack frame to large, so doing resarch i cleaned up all my unused declarations and changed all my int's to unsigned chars(that s all i need anyway), with that i was able to get my stack size up to 120, from 60 or 80, I also read a trick that you can use pointers or something, but i'd like to avoid that if i can since they seem a little confusing, PLUS during my reading everyone who was having large buffer issues were using much larger arrays, and cow didnt have this problem, so i am surprised that i am now, im sure its something simple im missing.?
THE 18f4620 should be able to handle this....
b) i borrowed the following code from another thread here, and it seems to work ok, but it causes me grief if i use it in this loop, where the variable CNT gets set and stuck at 0 after the second or third cycle(all that i can see is that maybe: EECON2 = 0xaa; <---arnt those supposta be capital a's)
for (CNT=1;CNT<80;CNT++) {WriteEEPROM (CNT,10);}
unsigned char ReadEEPROM(unsigned char address){
EECON1=0; //ensure CFGS=0 and EEPGD=0
EEADR = address;
EECON1bits.RD = 1;
return(EEDATA);
}
void WriteEEPROM(unsigned char address,unsigned char data){
char SaveInt;
SaveInt=INTCON; //save interrupt status
EECON1=0; //ensure CFGS=0 and EEPGD=0
EECON1bits.WREN = 1; //enable write to EEPROM
EEADR = address; //setup Address
EEDATA = data; //and data
INTCONbits.GIE=0; //No interrupts
EECON2 = 0x55; //required sequence #1
EECON2 = 0xaa; //#2
EECON1bits.WR = 1; //#3 = actual write
INTCON=SaveInt; //restore interrupts
while(!PIR2bits.EEIF); //wait until finished
EECON1bits.WREN = 0; //disable write to EEPROM
}
c) since im here, im also wondering about assembly, i wanted to avoid it all together but i never knew how close to it i was anyway, reading the datasheets im seeing the similarities but maybe there is a SIMPLE tutorial that guides me through all that garble?