0

I've recently started exploring and reading about Microchip's PIC32 MCUs, most specifically for motor control. I had some job done over the years but was a long while and haven't used the IDE with evaluation board since university years. Been using Arduino-compatible boards since or boards, compatible with the Arduino IDE.

So I'm running MPLAB X IDE v6.05 with the latest XC32 Compiler. My Development board is DT100113 Curiosity Pro board, utilizing PIC32MK0512MCJ064 MCU and an on-board PicKit4 (PKoB4) for programming/debugging/serial connection purposes.

What I try to do is light up the two user LEDs on pins RA10 and RE13 respectively.

As I begin with creating new project, select my device, my program/debug tool and give my project a name, next step is to create a new main.c file.

I create the file and write the following:

#include <stdio.h>
#include <stdlib.h>

#include <xc.h>


int main(int argc, char** argv) {

    //Define corresponding port bits as outputs (0 = output, 1 = input).
    TRISAbits.TRISA10 = 0;
    TRISEbits.TRISE13 = 0;
    
    //Latch the outputs to HIGH (1) and hold.
    while(1)
    {
        LATAbits.LATA10 = 1;
        LATEbits.LATE13 = 1;
    }
    return (EXIT_SUCCESS);
}

When I build and run it - nothing happens. Build is successful, connected to programmer, erase/flash device OK, but nothing with the LEDs.

I think I'm missing the #pragma directives (read about that it must be defined first prior anything else), but am unaware on how to set configuration bits (used peripherals, internal clock speed, etc.).

Any pointers to how-to articles, posts, etc. will be highly appreciated. I was not able to find step-by-step tutorial for my development board so far :((

Thank you in advance!

Cheers, Iliyan

I tried creating a new project, it compiled and ran, but the LEDs were not lit. Obviously was missing some vital parts in the code.

Rob
  • 14,746
  • 28
  • 47
  • 65

1 Answers1

0

Application software examples and driver libraries are included as part of the MPLAB Harmony V3 Framework. Add Harmony to 'Embedded' under the 'Tools' tab of the MPLAB IDE.

jolati
  • 700
  • 11
  • 19
  • Thank you very much for the response! Now it's latching the output bit HIGH. However, when I try to modify the code, i.e. LATEbits.LATE13 = 0; and click 'Run' - nothing happens. I start to think there is some major bug in the MPLAB X. – Iliyan Tomov Feb 18 '23 at 21:47
  • It appears that the program isn't reaching your modified line the second time you run. Halting after starting in debug mode will show where you are. Inserting breakpoints earlier in the code and single-stepping can reveal how you got there. – jolati Feb 20 '23 at 14:52
  • Hi, I don’t know if it’s the code. Whenever I restart MPLAB X, it uploads the changes code. But again only once. I do not know how to determine if it’s code, programmer or the IDE. Cheers, Iliyan – Iliyan Tomov Feb 21 '23 at 15:15
  • 1
    It was a bug in the MPLAB X IDE with the PKoB4. There was an update pack. Fixed the issue. Now everything works. – Iliyan Tomov Mar 10 '23 at 21:49
  • @IliyanTomov thanks for posting your solution, it may help someone in the future. – jolati Mar 12 '23 at 14:32