View previous topic :: View next topic |
Author |
Message |
mengtashou103
Joined: 27 Jan 2018 Posts: 5
|
Debug PIC18F16Q40 with MPlab SNAP programmer |
Posted: Mon Jan 20, 2025 2:51 pm |
|
|
Code: |
#include <18F16Q40.h>
#include <stdio.h>
#include <stdlib.h>
#fuses RSTOSC_LFINTRC, LVP, NOWDT
#use delay(clock=32k)
/*
*
*/
void main ()
{
set_tris_b(0x00);
while(1)
{
output_toggle(PIN_B6);
delay_ms(1000);
}
}
|
I was trying to program and debug PIC18F16Q20 with MPlab SNAP programmer. According to SNAP user guide, it required LVP. I have no problem using it to program the chip with the above program after enable the LVP bit in #fuse. But when I tried to debug the program, it gave me error notice: "Programming did not complete. The low voltage programming feature requires the LVP configuration bit to be enabled on the target device. Please enable this configuration bit and try the operation again."
Seems like LVP bit was not enabled when in debugging mode. Any idea about that? I was using MPLAB X IDE with CCS compiler plugin.[/list] |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9294 Location: Greensville,Ontario
|
|
Posted: Mon Jan 20, 2025 3:27 pm |
|
|
curious, I downloaded the datasheet. have a read of ICSP programming (chapter 43 ? )
I've never used LVP in 2 decades...is it a 'SNAP' requirement ?
edit: OK, found out SNAP is ONLY LVP.....
if so you may have to erase the PIC and 'start over'.
I'm sure those who have used SNAP will reply,may take a few hours though. PICS are used all over the World !!
OK, I re-read your post, got me thinking as it's cold here....
There are some PICs, that I can't program on my PICkit3 some combination of MCLR / clock/ ?? My cheat was to just use a different PIC.
You said you CAN program it, so I assume a '1Hz LED' program does flash an LED ?
If so, it's the 'DEBUG' mode of operation that doesn't work. I know 'debug' will configure a PIC differently than 'release' build configuration does. Since I don't use 'debug', I can't tell you 'how or why' it fails, just that it is different.
Maybe Mr. T will reply, his head is FULL of 'bits and bytes' about these PICs !!
Last edited by temtronic on Mon Jan 20, 2025 7:01 pm; edited 1 time in total |
|
|
mengtashou103
Joined: 27 Jan 2018 Posts: 5
|
|
Posted: Mon Jan 20, 2025 7:00 pm |
|
|
temtronic wrote: | curious, I downloaded the datasheet. have a read of ICSP programming (chapter 43 ? )
I've never used LVP in 2 decades...is it a 'SNAP' requirement ?
edit: OK, found out SNAP is ONLY LVP.....
if so you may have to erase the PIC and 'start over'.
I'm sure those who have used SNAP will reply,may take a few hours though. PICS are used all over the World !! |
Yeah, it only take LVP.
I also found out something with the CCS compiler. If I just normally compiled the code, it has LVP was enable in the LST file. But if I compiled the code for debugging, some config bit was force to be compatible with the debugger. I think that why it worked to just program the chip, but not worked for debugging. Not sure how to solve this.
Below was the config fuses setting in the LST file:
Normal build:
Code: |
Configuration Fuses:
Word 1: FFDC NOEXTOSC RSTOSC_LFINTRC NOCLKOUT PRLOCK1WAY CKS FCMEN PFCMEN SFCMEN
Word 2: FFF7 MCLR NOPUT NOMVECEN IVT1WAY NOLPBOR BROWNOUT BORV19 ZCDDIS PPS1WAY STVREN LVP NOXINST
Word 3: FF9F WDTSW NOWDT WDTWIN_SW WDTCLK_SW
Word 4: FFFF BBSIZ512 NOBOOTBLOCK NOSAF NODEBUG NOWRTB NOWRTC NOWRTD NOWRTSAF NOWRT
Word 5: FFFF NOPROTECT
Word 6: 0000
Word 7: 0000
Word 8: 0000
Word 9: 0000
|
Build for debugging
Code: |
Configuration Fuses:
Word 1: FFDC NOEXTOSC RSTOSC_LFINTRC NOCLKOUT PRLOCK1WAY CKS FCMEN PFCMEN SFCMEN
Word 2: CF37 MCLR NOPUT NOMVECEN IVT1WAY NOLPBOR NOBROWNOUT BORV19 ZCDDIS PPS1WAY NOSTVREN NOLVP NOXINST
Word 3: FF9F WDTSW NOWDT WDTWIN_SW WDTCLK_SW
Word 4: FFDF BBSIZ512 NOBOOTBLOCK NOSAF DEBUG NOWRTB NOWRTC NOWRTD NOWRTSAF NOWRT
Word 5: FFFF NOPROTECT
Word 6: 0000
Word 7: 0000
Word 8: 0000
Word 9: 0000
Some fuses have been forced to be compatible with the ICD debugger.
|
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9294 Location: Greensville,Ontario
|
|
Posted: Mon Jan 20, 2025 7:16 pm |
|
|
Well you've confirmed what I was thinking !
DEBUG requires a different 'configuration' to work.
I've always done 'debug' in the Real World, even got Microchip to change MPLAB v8.?? to allow 'release' to be the default build configuration for me. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19619
|
|
Posted: Tue Jan 21, 2025 1:50 am |
|
|
You may not be able to debug using LVP.
Historically in the ICD3, the manual states you have to disable LVP to
use debug. A few more searches find the same thing on other programme
I'll see if I can find the debug control specifications for that chip when I
have a moment, but I suspect there may be issues with this. |
|
|
mengtashou103
Joined: 27 Jan 2018 Posts: 5
|
|
Posted: Wed Jan 22, 2025 4:35 pm |
|
|
Seems like the problem was solved now.
As I mentioned in the previous post, the config bit of LVP was automatically set to disabled in CCS when it compiled for debugging purposes.
This setting could be changed in CCS compiler. Go to TOOL>DEVICE EDITOR and select the chip, then select ICD INTERFACE and remove NOLVP from the list. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9294 Location: Greensville,Ontario
|
|
Posted: Wed Jan 22, 2025 4:49 pm |
|
|
nice, you've got a solution !
It seems whatever 'defaults' are that the original programmer made are always NOT the 'defaults' I need. |
|
|
dmitrboristuk
Joined: 26 Sep 2020 Posts: 58
|
|
Posted: Thu Jan 23, 2025 1:23 am |
|
|
SNAP is a cut-down PIC KIT 4. As far as I understand, it does not have a debug mode. Use PIC KIT 3 |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9294 Location: Greensville,Ontario
|
|
Posted: Thu Jan 23, 2025 6:58 am |
|
|
gee, I've got two PICkit3's here, never used debug and if I look hard enough I KNOW I have two PICStart+ units 'somewhere'...
curious, anyone else 'played with PICs' for 25 years !!! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19619
|
|
Posted: Thu Jan 23, 2025 8:10 am |
|
|
Yes, I manage over 30......
I posted here before that when MicroChip posted a 'history of the PIC' page,
I had to actually point out to them that I was using the 16C84 a year before
they claimed it was released!. Even worse, a few of those boards are still
in use!.
Whimper gently. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9294 Location: Greensville,Ontario
|
|
Posted: Thu Jan 23, 2025 1:04 pm |
|
|
OK, I don't feel like the 1st dinosaur but still 'upset' that some PICs have to be in -40* COLD !! |
|
|
|