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 CCS Technical Support

Multiplex Digital Display and EEPROM

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



Joined: 06 Dec 2005
Posts: 59

View user's profile Send private message

Multiplex Digital Display and EEPROM
PostPosted: Tue Aug 28, 2007 7:23 am     Reply with quote

PCH 4.014
18F2520

Dear,

I am driving a 3 Digit 7-Segment Display (888). To avoid visible flicker each of the 3 multiplex-pins is active for 2 ms using timer0 interrupt.

I am writing to internal EEPROM (approx. 10 write cycles) each 15 minutes to store the working hours of the unit and as one write cycle needs approx. 10 ms then I get visible flicker at the display for 100 ms. CCS seems to disable interrupts during write_eeprom(); and so the multiplexing is not working during this time.

has anyone an idea how to solve this problem?

Thanks for any help

Best Regards

nilsener
SET



Joined: 15 Nov 2005
Posts: 161
Location: Glasgow, UK

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Tue Aug 28, 2007 8:29 am     Reply with quote

You might have to by-pass CCS code and write directly to the EEPROM, your code would write each byte at a time and poll for write completion - see the data sheet for details! (leaving Timer0 interrupt enabled).

It's a pity that Microchip dont have a capability for automatic and flexible timer reload, would be ideal for this sort of application without having to service interrupts - maybe in later PICs...
Guest








PostPosted: Tue Aug 28, 2007 8:36 am     Reply with quote

Dear SET,

thank you for helping. Did I understand right that you recommend to make it without using the CCS write_eeprom() command? I think you mean that I have to make my own code in Assembler?

Best Regards
Nilsener
SET



Joined: 15 Nov 2005
Posts: 161
Location: Glasgow, UK

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Tue Aug 28, 2007 8:43 am     Reply with quote

Maybe you wont need assembler (you can use #byte to map C variables to register addresses), but if CCS do indeed disable interrupts then you will have to write your equivalent to write_eeprom Sad . Any else done this before?
avro698



Joined: 11 Nov 2006
Posts: 9
Location: South Wales, UK.

View user's profile Send private message

PostPosted: Tue Aug 28, 2007 12:44 pm     Reply with quote

What size eeprom do you have?
Maybe it can be replaced with an FRAM (see www.ramtron.com)
This should improve/reduce access times - they advertise these parts as having 'NoDelay Writes'


698
SET



Joined: 15 Nov 2005
Posts: 161
Location: Glasgow, UK

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Tue Aug 28, 2007 3:22 pm     Reply with quote

Something like:

Code:
#byte EEADR = 0xFA9
#byte EEDATA = 0xFA8
#bit EECON1_EEPGD = 0xFA6.7
#bit EECON1_CFGS = 0xFA6.6
#bit EECON1_WREN = 0xFA6.2
#bit EECON1_WR = 0xFA6.1

void my_write_eeprom(int8 address, int8 value)
{
   EEADR = address;
   EEDATA = value;
   EECON1_EEPGD = 0;
   EECON1_CFGS = 0; // Access EEPROM
   EECON1_WREN = 1; // Enable writes
   disable_interrupts(GLOBAL);  // Disable Interrupts for 'special sequence'
   EECON2 = 0x55;     // required sequence
   EECON2 = 0xAA;
   EECON1_WR = 1;     // Set WR bit to begin write
   enable_interrupts(GLOBAL);
   EECON1_WREN =0; // Disable writes on write complete (EEIF set)
}


This is from the PIC18F2420 family datasheet, but should be similar to others. Just make sure you dont attempt to write the bytes too quickly - if you have a small delay (say 10mS) between each write then that will allow your timer interrupt code to run.
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