CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Write_EEPROM stops RS232 Interrupt

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Richard Sadler
Guest







Write_EEPROM stops RS232 Interrupt
PostPosted: Thu Jan 09, 2003 7:15 am     Reply with quote

hey, i have an pic16f877 running a display program (7 segment jobbies) on a bus (with lots of other stuff), the problem is that when i try to save the displays address into the pics eeprom with the Write_EEPROM command it stops the RS232 Working, i can only conclude that the write_EEPROM command some how either crashed the serial port or disables the interrupts, but i have tried to switch them back on, but it dosent work, i have an old version of PIC C, is there a known bug with old versions of PIC C which using the Write_EEPROM command, any help would be great!

Many Thanks
Richard Sadler
___________________________
This message was ported from CCS's old forum
Original Post ID: 10560
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: Write_EEPROM stops RS232 Interrupt
PostPosted: Thu Jan 09, 2003 12:29 pm     Reply with quote

:=hey, i have an pic16f877 running a display program (7 segment jobbies) on a bus (with lots of other stuff), the problem is that when i try to save the displays address into the pics eeprom with the Write_EEPROM command it stops the RS232 Working, i can only conclude that the write_EEPROM command some how either crashed the serial port or disables the interrupts, but i have tried to switch them back on, but it dosent work, i have an old version of PIC C, is there a known bug with old versions of PIC C which using the Write_EEPROM command, any help would be great!
-------------------------------------------------------
Post your compiler version. You can see it at the top
of the .LST file after you compile.
___________________________
This message was ported from CCS's old forum
Original Post ID: 10569
Richard Sadler
Guest







Re: Write_EEPROM stops RS232 Interrupt
PostPosted: Fri Jan 10, 2003 4:03 am     Reply with quote

Sorry to waste your time, but i have fixed to problem by writing a ASM vertion of the Write_EEPROM
if any one wants it here it is:

// EEPROM Definitions for writes
// put these at the top of your file
#byte STATUS = 0x183
#byte INTCON = 0x18b
#byte EECON1 = 0x18c
#byte EECON2 = 0x18d
#byte EEDATA = 0x10c
#byte EEADR = 0x10d

void WriteToEEPROM (byte Addr, byte Value)
{
EEDATA = Value;
EEADR = Addr;
#ASM
BSF STATUS, 6
BSF STATUS, 5
BCF EECON1, 7
BSF EECON1, 2
BCF INTCON, 7
MOVLW 0x55
MOVWF EECON2
MOVLW 0xAA
MOVWF EECON2
BSF EECON1, 1
BSF INTCON, 7
LOOP:
BTFSC EECON1, 1
GOTO LOOP
BCF EECON1, 2
#ENDASM
}

This seems to solve the problem because i havent seen it when using this code and the code works so im happy!
___________________________
This message was ported from CCS's old forum
Original Post ID: 10589
darren logan
Guest







Re: Write_EEPROM stops RS232 Interrupt
PostPosted: Sun Jan 12, 2003 3:21 am     Reply with quote

Richard,

Couple of points:

1. If you look at the PIC data sheet EEprom section, the assembly language example read/writes show that interrupts are indeed turned off whilst working with EEprom.
The compiler should manage the interrupts for us whilst communicating with EEprom but clearly in some versions of the compiler it doesn't, thus you need to do it manually !

2. I have 3 versions of the compiler, all in the early 3.xxx's.
I get the same problem for all 3 versions !
In fact, my problem was worse because a read_ or write_eeprom actually made my PIC16F870 hang or crash. Note that I had timer2 and rda interrupts all running at the same time so I am pushing my PIC to it's limits.

The way I handled it was before any read_ or write_eeprom, I disabled timer2 and rda interrupts, then did the EEprom stuff, then re-enabled the interrupts after. It seems to work.

For example:

if(serviceupdate) {
DisableInts();
serviceupdate=false;
writeword(EESERVHOURSL,servicedone); // update eeprom with hours in service
EnableInts();

void DisableInts(void) { // this proc. was necessary to cure "hanging"

disable_interrupts(int_timer2);
disable_interrupts(int_rda);
while(doingrda) { // wait until rda int has finished
}
}

void EnableInts(void) {

enable_interrupts(int_timer2);
enable_interrupts(int_rda);
}



- Notice also in my Disableints() routine, I wait for the rda interrupt to finish processing before exiting. I do this by setting "doingrda" to true at the start of the rda interrupt, and resetting it to false at the very end thus:

#int_rda
rda_isr() { // RS485 serial char in service routine

doingrda=true;
string[RS485StrPointer]=fgetc(RS485);

if(string[RS485StrPointer]==':') {
RS485StrPointer=1;
}
else {
RS485StrPointer++;
if(RS485StrPointer>=21) {
RS485StrPointer=0;
if(string[0]==':') {
DoSerialProcess=true;
}
}
}
doingrda=false;
}


Hope this is of some help !

Regards,
Darren
___________________________
This message was ported from CCS's old forum
Original Post ID: 10623
phord
Guest







Re: Write_EEPROM stops RS232 Interrupt
PostPosted: Sun Jan 12, 2003 4:36 pm     Reply with quote

:=- Notice also in my Disableints() routine, I wait for the rda interrupt to finish processing before exiting. I do this by setting "doingrda" to true at the start of the rda interrupt, and resetting it to false at the very end thus:

Uh... what? How would you ever be in some other code while also in your RDA interrupt routine? This chip isn't multi-threaded... it's interrupt driven. I think you should look at your logic more closely. It may be that you fixed your problem, but probably not the way you think you did.
___________________________
This message was ported from CCS's old forum
Original Post ID: 10633
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group