Can't read memory program.

Can't read memory program.

Postby JuanjoAlm » Thu Aug 27, 2020 9:45 am

We are working with a PIC24FJ512GA606. The problem is that we can't read the PIC with IPE or MPLAB X IDE.

We have configured this with Dual Partition and we have a bootloader. The configuration bits from both App and Bootloader are the same:

// FSEC
#pragma config BWRP = OFF
#pragma config BSS = DISABLED
#pragma config BSEN = OFF
#pragma config GWRP = OFF

#pragma config GSS = DISABLED
#pragma config CSS = DISABLED

#pragma config CWRP = OFF
#pragma config AIVTDIS = OFF

// FOSCSEL
#pragma config FNOSC = PRIPLL
#pragma config PLLMODE = PLL96DIV2
#pragma config IESO = ON

// FOSC
#pragma config POSCMD = XT
#pragma config OSCIOFCN = ON
#pragma config SOSCSEL = ON
#pragma config PLLSS = PLL_PRI
#pragma config IOL1WAY = OFF
#pragma config FCKSM = CSDCMD

// FWDT
#pragma config WDTPS = PS8192
#pragma config FWPSA = PR128
#pragma config FWDTEN = ON
#pragma config WINDIS = OFF
#pragma config WDTWIN = WIN25
#pragma config WDTCMX = WDTCLK
#pragma config WDTCLK = LPRC

// FPOR
#pragma config BOREN = ON
#pragma config LPCFG = OFF
#pragma config DNVPEN = ENABLE

// FICD
#pragma config ICS = PGD2
#pragma config JTAGEN = OFF
#pragma config BTSWP = OFF

// FDEVOPT1
#pragma config ALTCMPI = DISABLE
#pragma config TMPRPIN = OFF
#pragma config SOSCHP = ON
#pragma config ALTVREF = ALTREFEN

// FBOOT
#pragma config BTMODE = DUAL // Boot Mode Configuration bits->Device is in Dual Boot mode

When we try to read, we read the whole partition one to F's and the partition 2 to 0's.
JuanjoAlm
 
Posts: 4
Joined: Thu Aug 13, 2020 4:33 pm
PIC experience: Professional 1+ years with MCHP products

Re: Can't read memory program.

Postby AussieSusan » Fri Aug 28, 2020 6:13 am

Looking at http://ww1.microchip.com/downloads/en/D ... 05182a.pdf I see:

4.3.4 RULES FOR IN-CIRCUIT SERIAL PROGRAMMING™ (ICSP™)
When the device is connected to a device programmer, the allowable operations are limited to
erasing, programming and verifying the device code, and data Flash memory. The device programmer will use Chip, Partition or Page Erase commands to erase the device and clear the
Code Protection. ICSP programming may only proceed on an unprotected General Segment,
which is not write-protected. Attempts to verify code-protected segments within the device will
return ‘0’s. Once the device is programmed with the desired code and Boot mode, the Configuration bits are written to enable the Code Protection level. After this operation, the only way to
change the device code is by the code itself, or by ICSP erasure and clearing the Code Protection
once more.

For whatever reason the fact you are reading all '0's would indicate that code protection is turned on for your partition 2.
Reading all 'FF's would indicate that the partition has been erased but not programmed.
I've not used that chip and you have not shown the context for the pragma settings (e.g. have you got macro's that define OFF to be 0 and ON to be 1) which might totally mess up the values being set.
Susan
AussieSusan
Verified identity
 
Posts: 138
Joined: Mon Jun 16, 2014 4:45 am
PIC experience: Experienced Hobbyist

Re: Can't read memory program.

Postby ric » Sun Aug 30, 2020 1:01 am

AussieSusan wrote:...I've not used that chip and you have not shown the context for the pragma settings (e.g. have you got macro's that define OFF to be 0 and ON to be 1) which might totally mess up the values being set.
Susan

I've seen this before, and that is why Microchip recommend that all #include lines appear AFTER the "#pragma config" lines, not before.
As Susan mentioned, if something #defines "OFF" or "ON" it will probably corrupt the config settings.
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 581
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products


Return to PIC24

Who is online

Users browsing this forum: No registered users and 1 guest