PIC32 - T795 - problem running a programm

Started by tome.matos, January 15, 2014, 05:16:56 AM

Previous topic - Next topic

tome.matos

Hi all !

I'm having some trouble when I try do run a simple blinking led (LED1 - RB15) program in the microcontroller. It has been programmed with the Duinomite Bootloader.
I'm using the USB Bootloader application to send the .hex file but then I can't execute my program and I don't understand why.

Any help please?

Tome






Lurch

Possibly you are compiling in debug mode?
Did you set the needed ports to digital?

tome.matos

#2
I'm using MPLAB and I've just built the project, not in debug mode.

Here's my code:

#include <p32xxxx.h>
#include <plib.h>

#define SYSCLK 80000000L // System clock frequency, in Hz

void delay (unsigned);
int main(int argc, char** argv)
{
    // Set B15 as digital outpout
      TRISBbits.TRISB15 = 0;

    // Loop
    while (1) {
        // Toggle B15
        PORTBbits.RB15 = !PORTBbits.RB15;

        delay(250); // wait 250ms
    }

    return (EXIT_SUCCESS);
}

void delay (unsigned int n_intervals)
{
   volatile unsigned int i;
   int CALIBRATION_VALUE = 10000;
   for(; n_intervals != 0; n_intervals--)
   {
      for(i = CALIBRATION_VALUE; i != 0; i--)
      {
      }
   }
}

I've already tryed to run this same programm in a PIC32 with Microchip Bootloader and it runs perfectly but in this I can't say the same...

JohnS

Maybe any of these:
you've not set any clocks
config fuses
linker (ld) input
assuming reading an output pin will do what you want

John

Lurch

RB15 is by default an analog pin - so you have to turn off the analog function for it.
Try looking up the commands for ANSELA and PORTSetPinsDigital etc.

tome.matos

Thanks for the feedback guys!

Although I still couldn't solve the problem.
I don't have the linker file. How may I get it ?

JohnS

Must be somewhere in MPLAB.  Hunt around.

John

Lurch

normally it's in Microchip\mplabc32\v2.02\pic32mx\lib\ldscripts
actually, the compiler should find it without any special effort - if the installation was correct.
Maybe it would help to re-install the compiler.
What is the actual 'build' output?

tome.matos

#8
I've already found the linker ld.
The 'build' output is:

make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `C:/Users/Tome/Desktop/Universidade/5Ano/Tese/Projecto/Software/Firmware/sample-programs/LedBlink.X'
make  -f nbproject/Makefile-default.mk dist/default/production/LedBlink.X.production.hex
make[2]: Entering directory `C:/Users/Tome/Desktop/Universidade/5Ano/Tese/Projecto/Software/Firmware/sample-programs/LedBlink.X'
make[2]: `dist/default/production/LedBlink.X.production.hex' is up to date.
make[2]: Leaving directory `C:/Users/Tome/Desktop/Universidade/5Ano/Tese/Projecto/Software/Firmware/sample-programs/LedBlink.X'
make[1]: Leaving directory `C:/Users/Tome/Desktop/Universidade/5Ano/Tese/Projecto/Software/Firmware/sample-programs/LedBlink.X'

BUILD SUCCESSFUL (total time: 134ms)
Loading code from C:/Users/Tomé/Desktop/Universidade/5º Ano/Tese/Projecto/Software/Firmware/sample-programs/LedBlink.X/dist/default/production/LedBlink.X.production.hex...
Loading symbols from C:/Users/Tomé/Desktop/Universidade/5º Ano/Tese/Projecto/Software/Firmware/sample-programs/LedBlink.X/dist/default/production/LedBlink.X.production.elf...
Loading completed

Whats making me confused is the that I can run the problem perfectly in another microcontroller with the same microprocessor (PIC32MX795F512H) ...

A question: the PIC32 T795 should be detected in a USB port without being in the update mode?

JohnS

It will not be seen as a USB device unless it your user code sets it up correctly to do that.

(USB is optional, via software.)

John

LubOlimex

Hey Tome,

I tried your code – with the proper linker script I managed to upload it to the board via the bootloader application. However, the desired blink effect didn't work here either.

The code seems correct but I feel like the problem is related either to configuration bits of the project or to the compiler. As long as the bootloader application is able to upload to the board then the linker script should be ok. I believe the problem is somehow related to the code (despite that the initialization and the toggling part seem correct) but I was unable to fix it.

Best regards,
Lub/OLIMEX
Technical support and documentation manager at Olimex