How to make PICkit 4 work with SAM and Atmel Studio 7?

Go To Last Post
23 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

To be able to design a custom board, I am first trying to understand how to use the PICkit 4 in-circuit debugger with SAM and Atmel Studio 7. Before I design the custom board, I would like to try to use the PICkit 4 in-circuit debugger on a SAM E70 XPlained evaluation board using the 20-pin header J403.

From the SAM x70 series datasheet, I see in Fig. 60-1 the following:

 

 

First of all, is this the right interface to use for programming and, if possible, even for debugging purposes?

What are the right connections from the PICkit 4 to the SWD?

 

 

 

I am assuming the correct connections are as follows:

    (1) nMCLR     = nRST
    (3) Ground    = Ground

    (4) PGD       = TRACESWO
    (5) PGC       = SWCLK
    (8) <unnamed> = SWDIO

VDD between the board and the programmer need to be independent (I would power the board separately via the USB cable).

I sort of figured the SWDIO from the following table (which I found here):

 

Has anyone tried this out before? Has anyone used PICkit 4 successfully in combination with Atmel Studio 7?

 

 

Last Edited: Fri. May 1, 2020 - 09:51 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 Vtg needs to be connected.  On the pk4, it senses target voltage rather than supplying power.

 

ibe successfully used a pickit4 to talk to a samc, but I don’t recall whether I used as7 or mplabx.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

westfw wrote:

 Vtg needs to be connected.  On the pk4, it senses target voltage rather than supplying power.

 

ibe successfully used a pickit4 to talk to a samc, but I don’t recall whether I used as7 or mplabx.

 

Alright, thanks for the input.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

OK, so for anyone who wants to go the same route as I did, here's a little guide:

 

I built the following connections:

 

 

I've actually got this to work with the SAM E70 XPlained board using the connector J406.

There's an option to use the PICkit 4 in Atmel Studio 7. However, it appears to be working only with AVR not SAM no

 

So I opened MPLAB X IDE, created a new project and selected PICkit 4. I was worried I'd have to rewrite my whole code. But if you continue your development in AS7, you can just write the .hex code that is created by AS7 in project properties:

 

 

It's not the ideal solution because it does not allow coding in AS7 while using a custom board but at least I know now that I can use the PICkit 4 and don't need to buy the expensive Atmel ICE.

 

Last Edited: Sat. May 2, 2020 - 10:06 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why haven't you connected SWDIO? That's your debug in/out pin...
.
TraceSWO is not needed (don't think the pk4 has SWO trace)

:: Morten

 

(yes, I work for Microchip, yes, I do this in my spare time, now stop sending PMs)

 

The postings on this site are my own and do not represent Microchip’s positions, strategies, or opinions.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

meolsen wrote:
Why haven't you connected SWDIO? That's your debug in/out pin... . TraceSWO is not needed (don't think the pk4 has SWO trace)

Why do you think I haven't connected it? I’ve used the PICkit 4 and was able to debug.

Last Edited: Sat. May 2, 2020 - 12:41 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I sent an email to Microchip to find out when Atmel Studio is planned to support PICkit 4 on SAM. Right now it only works on AVR.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Because I read your pinout wrong 😄

:: Morten

 

(yes, I work for Microchip, yes, I do this in my spare time, now stop sending PMs)

 

The postings on this site are my own and do not represent Microchip’s positions, strategies, or opinions.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Never received a reply from Microchip frown

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You might want to consider that Microchip is moving away from AS7 towards MPLAB. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:

You might want to consider that Microchip is moving away from AS7 towards MPLAB. 

 

That would be a major setback and there are at least two reasons. I've gone through getting everything set up in MPLab X IDE 5.40, so I've got the environment up and running. And the reasons are:

  • Getting my code compiled and the device programmed takes 30 seconds on my rig in MPLab. Even if I do not make any changes to my code. It takes a mere 2 seconds in Atmel Studio.
  • Atmel Studio allows to use optimization level 3 without the need for an extra license. MPLab asks you to buy a license.
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No use telling me - I don't use either!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:

No use telling me - I don't use either!

And what's the solution you are using, if I may ask?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

IAR or PlatformIO

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, how can I switch my PICKIT 4 from PIC to AVR mode? The Microchip studio IDE is giving me an option to switch it, but soon shows communication timeout. Also, how can I upgrade firmware on PICKIT 4 through Microchip studio?

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Currently the only way of upgrading the PICkit 4 FW is to use MPLAB X. Create a project in MPAB X (any target device will do) with PICkit 4 as the tool, and click on the button with the two circling arrows in the dashboard view in the lower left corner. That should upgrade the FW.

 

After you have upgraded the FW you should be able to change mode in Studio.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

Tried out your suggestion but still getting a few errors instead of firmware upgrading. Attached screenshots. Please check if the circled button is right.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, that's the right button. But I would expect it to do the FW upgrade before checking target voltage. Which FW version does it report in the log?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm attaching a screenshot of the firmware upgrade message im receiving in Microchip studio.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not in Studio. Studio can't upgrade the PICkit 4. I meant the log in MPLAB X. Here's how it looks like for me when I upgrade from 1.8.146 to 1.12.223 using the green-arrows-button:

PICkit 4 FW upgrade log

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, i was able to upgrade the firmware using MPLABX and it is now operating well in Microchip Studios. However I am getting a new error which I have attached. The pickit 4 isnt supplying required voltage to my target device and hence I cannot program the device. Can I make any changes to solve this?

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The PICkit 4 does (currently) not support supplying power when in AVR mode.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

I see. Have resolved the issue by adjusting external voltage supply to the device to 3.3v. Works just fine! Thanks for the help!