View previous topic :: View next topic |
Author |
Message |
nilsener
Joined: 06 Dec 2005 Posts: 59
|
Multiplex Digital Display and EEPROM |
Posted: Tue Aug 28, 2007 7:23 am |
|
|
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
|
|
Posted: Tue Aug 28, 2007 8:29 am |
|
|
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
|
|
Posted: Tue Aug 28, 2007 8:36 am |
|
|
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
|
|
Posted: Tue Aug 28, 2007 8:43 am |
|
|
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 . Any else done this before? |
|
|
avro698
Joined: 11 Nov 2006 Posts: 9 Location: South Wales, UK.
|
|
Posted: Tue Aug 28, 2007 12:44 pm |
|
|
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
|
|
Posted: Tue Aug 28, 2007 3:22 pm |
|
|
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. |
|
|
|