PDA

View Full Version : PIC30f4012 Problems



Insane
- 27th July 2009, 10:10
Hi,

Were a group doing a final year project.
Part of this project is to get a BLDC Motor spinning.
The story goes as follows...

We had the motor running ... all sweet, usually we could have the motor running whilst interupting for a few seconds to program the chip with a slightly modified code, and then the motor would continue to run.

However.... one day when programming the chip, the motor stopped and has never spun since. We had PWM working as outputs when the hall sensors were in specific positions and after this download of the code, we had NOTHING.

We swapped chips to another on which had the working code on it... motor working all sweet again... reprogrammed it .... FAIL.

Now after checking over everything for the last week still to no avail, we cannot even write and produce a simple "Turn on a Port" program and have it working on a breadboard.

Weve tried different chips, computers, PICKITS(Another PICKIT3 aswell as another PICKIT2).

The program builds fine and the program is verified after programming... everything happens as it should except for any sort of output at the pins..

Were using PIC30f4012 with PICKIT3, running MPLAB IDE v8.30 with C30 compiler.

At the moment all weve got is the In-Circuit-Programming and the chip on the breadboard.

The basic code is below for tuning on an LED at each port listed in the code.

----------------------------------------
#include "htc.h"
#include "p30f4012.h"
#include "stdlib.h"

void init(void)
{
ADPCFG = 0xFFFC;
TRISB = 0b000000;
TRISD = 0b00;

TRISC = 0x9fff; // RC13 and RC14 are outputs

TRISD = 0xfffc; // RD0 & RD1 are outputs

TRISE = 0xffc0; // RE0 - RE5 (PWMs) are outputs

PORTF = 0;
TRISF = 0xffff;
}


void main(void)
{
init();
while(1){

PORTBbits.RB1 = 1;
PORTDbits.RD1 = 1;
PORTDbits.RD0 = 1;

}
}


--------------------------------------



Thanks all, hope you can state the obvious!!

Archangel
- 28th July 2009, 08:34
Hi,

Were a group doing a final year project.
Part of this project is to get a BLDC Motor spinning.
The story goes as follows...

We had the motor running ... all sweet, usually we could have the motor running whilst interupting for a few seconds to program the chip with a slightly modified code, and then the motor would continue to run.

However.... one day when programming the chip, the motor stopped and has never spun since. We had PWM working as outputs when the hall sensors were in specific positions and after this download of the code, we had NOTHING.

We swapped chips to another on which had the working code on it... motor working all sweet again... reprogrammed it .... FAIL.

Now after checking over everything for the last week still to no avail, we cannot even write and produce a simple "Turn on a Port" program and have it working on a breadboard.

Weve tried different chips, computers, PICKITS(Another PICKIT3 aswell as another PICKIT2).

The program builds fine and the program is verified after programming... everything happens as it should except for any sort of output at the pins..

Were using PIC30f4012 with PICKIT3, running MPLAB IDE v8.30 with C30 compiler.

At the moment all weve got is the In-Circuit-Programming and the chip on the breadboard.

The basic code is below for tuning on an LED at each port listed in the code.

----------------------------------------
#include "htc.h"
#include "p30f4012.h"
#include "stdlib.h"

void init(void)
{
ADPCFG = 0xFFFC;
TRISB = 0b000000;
TRISD = 0b00;

TRISC = 0x9fff; // RC13 and RC14 are outputs

TRISD = 0xfffc; // RD0 & RD1 are outputs

TRISE = 0xffc0; // RE0 - RE5 (PWMs) are outputs

PORTF = 0;
TRISF = 0xffff;
}


void main(void)
{
init();
while(1){

PORTBbits.RB1 = 1;
PORTDbits.RD1 = 1;
PORTDbits.RD0 = 1;

}
}


--------------------------------------



Thanks all, hope you can state the obvious!!

Wow, where do I start? The obvious, PIC BASIC & PBP is not "C", PIC Basic & PBP does not do 16 or 32 bit PICs, Don't want to send anyone away still hungry . . . Sounds like your "NEW" code has a very glaring problem, I would concentrate on what is different from what worked. Have you changed the configs without realizing it ? Did you upgrade the compiler ?

Art
- 17th June 2010, 12:35
Well while we're totally off the topic of the whole forum,
My car has this problem where the engine stutters when it's idling,
and the gear change is slack. I wonder if they are two separate problems or the same thing??

Seriously,
@ Insane, I just got started with Microchip's C30, but since I haven't had to begin a program,
(just modify one), I haven't had to configure chips, and pin outputs, etc.

However, I can see that your while(1) loop turns ports on, and that's all it does.
Nothing ever changes after that.
Have you set up the clock properly? some of the dsPics have a PLL that needs to be configured
even though you've connected the crystal.

Maybe you should start out with a Microchip development board so you can begin with
both hardware and software that you know is correct, and then go about changing things.

Maybe join Microchip's forum:
http://www.microchip.com/forums/tm.aspx?m=456772&mpage=1&key=CRT0_STARTUP��
where they have a section that specifically deals with their C30 compiler.

Now about my car.....

Acetronics2
- 17th June 2010, 13:09
Hi, Art

I wonder ...

Doesn't your car clock have a problem too ... ??? :D

Let's Hope Insane has got an answer ... since last year ...

Alain

Art
- 18th June 2010, 07:16
Ah, is the picbasic section that slow or did I find the thread in a search???

Apologies :D