View previous topic :: View next topic |
Author |
Message |
nostep
Joined: 04 Mar 2009 Posts: 16
|
dsPic30F6012A won't run |
Posted: Wed Mar 04, 2009 6:21 pm |
|
|
I have a professionally produced circuit board of my own design with a dsPic30F6012A process and a 10mhz crystal. I had an older ICD-U40 and it wouldn't program. I bought a new one and the programming seems to work. Verify says it's correct. Problem is no blinking LED! I am a very experienced programmer with 18Fs and older, but this one is driving me nuts. LEDs are on PIN_G2 and PIN_G3. I am using latest CCS compiler and 24 bit wiazrd with minimal options.
Anyone have a super simple code snippet I can try?
Are the wire lengths to the ICD super critical (about 18" right now)?
Again, it seems to program, but not run. Debug doesn't seem to work either.
Thanks |
|
|
Guest
|
|
Posted: Thu Mar 05, 2009 9:35 am |
|
|
Update, processor runs and i can say "Hello World" through the serial port. Problem is, individual output lines are not working.
Code is simple:
Code: | main()
{
output_high(pin_g7);
etc . . .
} |
pin does not go high . . . |
|
|
andreluizeng
Joined: 04 Apr 2006 Posts: 117 Location: Brasil
|
|
Posted: Thu Mar 05, 2009 1:45 pm |
|
|
post the list part so we can see what is going on... but anyway, have you tried to set this pin high without ccs built-in function ???
Code: |
#byte PORT_G = 0x2E6
#bit PIN_G7 = PORT_G.7
#byte TRIS_G = 0x2E4
#bit TRIS_G7 = TRIS_G.7
|
and then..
Code: |
main()
{
TRIS_G7 = 0; // output
PIN_G7 = 1; //high
etc . . .
}
|
regards. _________________ Andre |
|
|
nostep
Joined: 04 Mar 2009 Posts: 16
|
|
Posted: Thu Mar 05, 2009 7:01 pm |
|
|
Andre,
Good idea, I'll try that Friday and let you know.
Thanks,
John |
|
|
nostep
Joined: 04 Mar 2009 Posts: 16
|
|
Posted: Fri Mar 06, 2009 5:28 am |
|
|
The above code didn't work. I had to change pin_g7 to pins_g7 because pin_g7 was already defined. Still didn't turn the port on. |
|
|
nostep
Joined: 04 Mar 2009 Posts: 16
|
|
Posted: Fri Mar 06, 2009 7:00 am |
|
|
OK, I have lots of IO pins working now, except for G7 and G8. I think it may have to do with the second function of these pins. Datasheets call out CN9 for pin G7 and CN10 for G8. How does one disable the "Capture Notification" feature on these pins? The third function of the pins, SPI2 is already disabled. |
|
|
andreluizeng
Joined: 04 Apr 2006 Posts: 117 Location: Brasil
|
|
Posted: Fri Mar 06, 2009 7:46 am |
|
|
could you post your entire code here ? including header file, so we can see better how you are initializating your dsPIc.
regards. _________________ Andre |
|
|
nostep
Joined: 04 Mar 2009 Posts: 16
|
|
Posted: Fri Mar 06, 2009 8:04 am |
|
|
Code: | -------------------------------------------------------
main4.c
-------------------------------------------------------
#include "main4.h"
#use rs232(UART1,baud=9600,parity=N,bits=8)
void main()
{
setup_spi(SPI_SS_DISABLED);
setup_spi2(SPI_SS_DISABLED);
setup_wdt(WDT_OFF);
setup_timer1(TMR_DISABLED);
set_tris_g(0x00);
while(1)
{
output_high(PIN_G7);
output_high(PIN_G8);
printf("Hello World\n");
delay_ms(1000);
}
} |
Code: | -------------------------------------------------------
main4.h
-------------------------------------------------------
#include <30F6012A.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES XT_PLL4
#FUSES PR_PLL //Primary Oscillator with PLL
#FUSES NOCKSFSM //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES WPSB16 //Watch Dog Timer PreScalar B 1:16
#FUSES WPSA512 //Watch Dog Timer PreScalar A 1:512
#FUSES PUT64 //Power On Reset Timer value 64ms
#FUSES NOBROWNOUT //No brownout reset
#FUSES BORV47 //Brownout reset at 4.7V
#FUSES LPOL_HIGH //Low-Side Transistors Polarity is Active-High (PWM 0,2,4 and 6)
//PWM module low side output pins have active high output polar
#FUSES HPOL_HIGH //High-Side Transistors Polarity is Active-High (PWM 1,3,5 and 7)
//PWM module high side output pins have active high output polarity
#FUSES NOPWMPIN //PWM outputs drive active state upon Reset
#FUSES MCLR //Master Clear pin enabled
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOCOE //Device will reset into operational mode
#FUSES ICS0 //ICD communication channel 0
#FUSES RESERVED //Used to set the reserved FUSE bits
#use delay(clock=40000000) |
|
|
|
andreluizeng
Joined: 04 Apr 2006 Posts: 117 Location: Brasil
|
|
Posted: Fri Mar 06, 2009 8:39 am |
|
|
it seems like the notification change (second function of the pin) is working, so you have to disable it.
lets try the following code regarding to disable CN interrupt:
main4.h
Code: |
#byte IEC0 = 0x008C // if it is already defined, then ignore this code and use the defined one
#bit CNIE = ICE0.15
|
main4.c
Code: |
#use rs232(UART1,baud=9600,parity=N,bits=8)
void main()
{
setup_spi(FALSE);
setup_spi2(FALSE);
setup_wdt(WDT_OFF);
setup_timer1(TMR_DISABLED);
disable_interrupts (GLOBAL); // disable global interrupts
CNIE = FALSE; // disable CNIE interrupt
set_tris_g(0x00);
while(1)
{
output_high(PIN_G7);
output_high(PIN_G8);
printf("Hello World\n");
delay_ms(1000);
}
} |
hope to get luck in this time
regards. _________________ Andre |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Fri Mar 06, 2009 10:57 am |
|
|
Peripheral modules as SPI or change notification are disabled by default. There's no need to disable them initially
(it doesn't hurt, of course, but only if you do it correctly).
Code: | setup_spi2(SPI_SS_DISABLED); | actually enables SPI2, just removing this instruction leaves it disabled and hopefully recovers PIN_G7 and PIN_G8 operation.
setup_spi2(FALSE) would be correct for disable, I think. |
|
|
nostep
Joined: 04 Mar 2009 Posts: 16
|
|
Posted: Fri Mar 06, 2009 11:05 am |
|
|
DUDE, YOU TOTALLY ROCK! Works Great! |
|
|
andreluizeng
Joined: 04 Apr 2006 Posts: 117 Location: Brasil
|
|
Posted: Fri Mar 06, 2009 11:29 am |
|
|
alright..
now good luck with your project.
regards. _________________ Andre |
|
|
nostep
Joined: 04 Mar 2009 Posts: 16
|
|
Posted: Fri Mar 06, 2009 12:38 pm |
|
|
Thanks, I appreciate everyones help. |
|
|
|