Simulation of Writes to Prog. Mem.

Discussion topics related to the 32-bit version of MPLAB IDE version 6.xx and later.

Simulation of Writes to Prog. Mem.

Postby tunelabguy » Wed Dec 24, 2014 9:25 pm

While waiting for my circuit boards to arrive, I have been developing my writes to Program Memory using the MPLAB v8.92 simulator. Here are a couple of things that have not turned out quite like the datasheet. It might be that the datasheet is wrong, or that the simulator is wrong, or that I just don't understand the datasheet. I will find out when I build my first board. But in the meantime:

The docs say that Prog. Mem erasure happens one complete row at a time. Different PICs have different row size. The PIC16f1823 that I am using says its erasure row size is 16 words. But when I execute the code for erasure in the simulator, the Prog. Mem view window in the simulator shows 32 words got erased, instead of 16.

Next I tried writing to the newly-erased region in Prog. Memory. Using the sample code in the datasheet as a guide, I wrote a varying number of consecutive words, starting at the beginning of the row. In each case the last word is written with the LWLO bit cleared, as explained in the datasheet, to make the writing of that group of words take effect. What I found by examining the Prog. Mem view window was that the words were not always all written:

Words attempted: 1 Words written: 0
Words attempted: 2 Words written: 0
Words attempted: 3 Words written: 0
Words attempted: 4 Words written: 4
Words attempted: 5 Words written: 4
Words attempted: 6 Words written: 4
Words attempted: 7 Words written: 4
Words attempted: 8 Words written: 8
Words attempted: 9 Words written: 8
...etc.

In other words, the number of words actually written was always the highest multiple of 4 that would fit.

Is it likely that everything will work as documented once I try it in real hardware?
User avatar
tunelabguy
Verified identity
 
Posts: 29
Joined: Sun Jul 20, 2014 9:41 pm
PIC experience: Professional 5+ years with MCHP products

Re: Simulation of Writes to Prog. Mem.

Postby ric » Wed Dec 24, 2014 9:56 pm

I wouldn't waste time tracking these sort of problems in the simulator.
Peripheral and flash memory operation are notoriously buggy. It's much more productive to test your own code on real hardware.
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products


Return to MPLAB 8 IDE

Who is online

Users browsing this forum: No registered users and 3 guests

cron