Page 2 of 2

Re: DANGEROUS PROBLEMS ACCESSING CONST CHAR ARRAYS within SALVO

PostPosted: Fri Jan 31, 2003 10:30 am
by aek
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 ...

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


Re: DANGEROUS PROBLEMS ACCESSING CONST CHAR ARRAYS within SALVO

PostPosted: Fri Jan 31, 2003 10:33 am
by aek
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 :-(

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


Re: DANGEROUS PROBLEMS ACCESSING CONST CHAR ARRAYS within SALVO

PostPosted: Fri Jan 31, 2003 10:37 am
by aek
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!

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


Re: DANGEROUS PROBLEMS ACCESSING CONST CHAR ARRAYS within SALVO

PostPosted: Fri Jan 31, 2003 12:25 pm
by jtemples
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.

Re: DANGEROUS PROBLEMS ACCESSING CONST CHAR ARRAYS within SALVO

PostPosted: Fri Jan 31, 2003 12:32 pm
by luben
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


Re: DANGEROUS PROBLEMS ACCESSING CONST CHAR ARRAYS within SALVO

PostPosted: Fri Jan 31, 2003 12:41 pm
by luben
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).]


Re: DANGEROUS PROBLEMS ACCESSING CONST CHAR ARRAYS within SALVO

PostPosted: Fri Jan 31, 2003 12:50 pm
by jtemples
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.