Pumpkin, Inc.

Pumpkin User Forums

DANGEROUS PROBLEMS ACCESSING CONST CHAR ARRAYS within SALVO

If you think you've found a bug or other mistake in your Salvo distribution, post it here.

Re: DANGEROUS PROBLEMS ACCESSING CONST CHAR ARRAYS within SALVO

Postby aek » Fri Jan 31, 2003 10:30 am

quote:
If an internal EEPROM write cycle is in progress, you cannot read from flash memory
Now THAT makes sense -- now I understand where Luben is coming from (the interaction of EEPROM write and Flash read).

If you can create a bare-bones example that shows how this fails, I suspect that Matt @ HI-TECH would be amenable to updating the compiler to handle this -- perhaps the packed-string-reading routine could be made to wait until EEPROM write is complete ...

------------------

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: DANGEROUS PROBLEMS ACCESSING CONST CHAR ARRAYS within SALVO

Postby aek » Fri Jan 31, 2003 10:33 am

Of course the other option for Luben is simply to wait until EEPROM write is done ... unfortunately, that takes many cycles (4-8ms as per the datasheet). That's a lot of cycles :-(

------------------

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: DANGEROUS PROBLEMS ACCESSING CONST CHAR ARRAYS within SALVO

Postby aek » Fri Jan 31, 2003 10:37 am

OK, so one more way to look at it is to use a binSem as a resource-control mechanism.

Namely, the binSem is used to indicate that a EEPROM/Flash write is in progress -- and any task that accesses Flash memory (e.g. in printf(), where the packed string is in Flash) must first wait the binSem and then only proceed when the resource is made available again.

In this scenario, only the task(s) that are printf()'ing packed strings will be forced to wait during an EEPROM write -- all other tasks can proceed.

It seems to me that this would be the best solution, as 4-8ms on even a 4MHz PIC is 4-8,000 instructions -- that's a long time to sit around doing nothing!

------------------

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: DANGEROUS PROBLEMS ACCESSING CONST CHAR ARRAYS within SALVO

Postby jtemples » Fri Jan 31, 2003 12:25 pm

quote:

perhaps the packed-string-reading routine could be made to wait until EEPROM write is complete


The downside there is that it would also have to disable interrupts while it was waiting, and while it was reading the string from flash -- as soon as WR goes low, you're going to get a write-complete interrupt, which might start another EEPROM write in the ISR.
jtemples
 
Posts: 45
Joined: Tue Jul 16, 2002 11:00 pm

Re: DANGEROUS PROBLEMS ACCESSING CONST CHAR ARRAYS within SALVO

Postby luben » Fri Jan 31, 2003 12:32 pm

Hello,

BinSem is not good idea to control the resources. Imagine that you have to put OS_WaitBinSem before ANY sprintf, or v=ARRAY[n] instruction (ARRAY is const byte).... it's crazy!!!!

Luben

luben
 
Posts: 324
Joined: Sun Nov 19, 2000 12:00 am
Location: Sofia, Bulgaria

Re: DANGEROUS PROBLEMS ACCESSING CONST CHAR ARRAYS within SALVO

Postby luben » Fri Jan 31, 2003 12:41 pm

Hello,

You can't wait the finishing of the EEPROM write in SALVO multitasking enviornment. I mean - there is no PROBLEM for linear programming, but in multitasking system is DANGEROUS. Imagine that 20MHz PIC have to wait 12ms every time you write to EEPROM!!! It's not multitasking at all.... it's crazy!

You wrote that you made the examples and all tehy work fine. I agree that you didn't saw the problem, it happens from time to time. As I told you I tried to locate it almost 2 weeks and more - I felt that something is not OK, but until I located the problem was not able to define the reason...
So, it happen from time to time. It's not a problem that could be easy reproduced, but it yields wrong data!

I have some unclear ideas how to fix this, but for sure it's not pure HiTech problem - it have to be solved from SALVO side as well.

Regards
Luben

[This message has been edited by luben (edited January 31, 2003).]

luben
 
Posts: 324
Joined: Sun Nov 19, 2000 12:00 am
Location: Sofia, Bulgaria

Re: DANGEROUS PROBLEMS ACCESSING CONST CHAR ARRAYS within SALVO

Postby jtemples » Fri Jan 31, 2003 12:50 pm

Unless you can't afford the ROM space, I would just compile with -no_string_pack. I don't see this as having anything to do with Salvo -- I have lots of non-Salvo code that will be broken by this compiler feature.

jtemples
 
Posts: 45
Joined: Tue Jul 16, 2002 11:00 pm

Previous

Return to Bug Reports

Who is online

Users browsing this forum: No registered users and 1 guest

cron