Welcome, Guest

Author Topic: PIC32 - T795 - problem running a programm  (Read 3943 times)

tome.matos

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
PIC32 - T795 - problem running a programm
« on: January 15, 2014, 05:16:56 AM »
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





« Last Edit: January 15, 2014, 04:22:23 PM by tome.matos »

Lurch

  • Sr. Member
  • ****
  • Posts: 272
  • Karma: +11/-0
Re: PIC32 - T795
« Reply #1 on: January 15, 2014, 08:33:54 AM »
Possibly you are compiling in debug mode?
Did you set the needed ports to digital?

tome.matos

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
Re: PIC32 - T795
« Reply #2 on: January 15, 2014, 01:32:21 PM »
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...
« Last Edit: January 15, 2014, 03:37:33 PM by tome.matos »

JohnS

  • Hero Member
  • *****
  • Posts: 1719
  • Karma: +33/-48
Re: PIC32 - T795 - problem running a programm
« Reply #3 on: January 15, 2014, 06:45:01 PM »
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

  • Sr. Member
  • ****
  • Posts: 272
  • Karma: +11/-0
Re: PIC32 - T795 - problem running a programm
« Reply #4 on: January 15, 2014, 08:51:51 PM »
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

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
Re: PIC32 - T795 - problem running a programm
« Reply #5 on: January 18, 2014, 04:26:56 AM »
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

  • Hero Member
  • *****
  • Posts: 1719
  • Karma: +33/-48
Re: PIC32 - T795 - problem running a programm
« Reply #6 on: January 18, 2014, 09:58:44 AM »
Must be somewhere in MPLAB.  Hunt around.

John

Lurch

  • Sr. Member
  • ****
  • Posts: 272
  • Karma: +11/-0
Re: PIC32 - T795 - problem running a programm
« Reply #7 on: January 18, 2014, 10:55:05 AM »
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

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
Re: PIC32 - T795 - problem running a programm
« Reply #8 on: January 18, 2014, 03:34:34 PM »
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?
« Last Edit: January 18, 2014, 03:40:04 PM by tome.matos »

JohnS

  • Hero Member
  • *****
  • Posts: 1719
  • Karma: +33/-48
Re: PIC32 - T795 - problem running a programm
« Reply #9 on: January 20, 2014, 05:46:20 PM »
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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1921
  • Karma: +50/-3
Re: PIC32 - T795 - problem running a programm
« Reply #10 on: January 22, 2014, 02:46:27 PM »
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