CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Debug PIC18F16Q40 with MPlab SNAP programmer

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mengtashou103



Joined: 27 Jan 2018
Posts: 5

View user's profile Send private message

Debug PIC18F16Q40 with MPlab SNAP programmer
PostPosted: Mon Jan 20, 2025 2:51 pm     Reply with quote

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: 9293
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Jan 20, 2025 3:27 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Jan 20, 2025 7:00 pm     Reply with quote

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: 9293
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Jan 20, 2025 7:16 pm     Reply with quote

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: 19617

View user's profile Send private message

PostPosted: Tue Jan 21, 2025 1:50 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jan 22, 2025 4:35 pm     Reply with quote

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: 9293
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Jan 22, 2025 4:49 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jan 23, 2025 1:23 am     Reply with quote

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: 9293
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Jan 23, 2025 6:58 am     Reply with quote

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 !!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group