|
|
View previous topic :: View next topic |
Author |
Message |
oOfenixOo
Joined: 06 Jun 2013 Posts: 3
|
MPLab ICD3 to program EiBot Board with CCS compiler |
Posted: Thu Jun 06, 2013 3:02 pm |
|
|
Hi everyone,
I tried to use an EiBot board from Sparkfun for my own project (https://www.sparkfun.com/products/10025). Basically, Its a PIC18F46J50 board with ICSP pin out (5 pins).
The thing is I use my MPLab ICD3. Which has 6 pins. 5 (PGC, PGD, VDD, VSS, Ground) of 6 match with the board ICSP 5 pins out. There a redundant one (PGM) I didn't connect with anything. I wrote a short program. "Build succeeded" and...
The problem is when I plug them all together, power on the EiBot board, open MPLab IDE, it can recognize the PIC but when It couldn't program it. I just tried to blink some LEDs but nothing happen.
Code: |
#include <18F46J50.h>
#fuses HSPLL,PLL5,NOWDT,NOPROTECT,DEBUG,NOCPUDIV,NODSBOR,NODSWDT,NOWPFP,NOWPCFG,NOWPDIS,NOFCMEN,NOIESO,RTCOSC_T1
#use delay(clock=31mhz)
void main(void)
{
set_tris_a(0xff);
set_tris_d(0x00);
while(1)
{
output_high(PIN_D0);
output_high(PIN_D1);
output_high(PIN_D2);
output_high(PIN_D3);
output_high(PIN_D4);
output_high(PIN_D5);
output_high(PIN_D6);
output_high(PIN_D7);
delay_ms(1000);
output_low(PIN_D0);
output_low(PIN_D1);
output_low(PIN_D2);
output_low(PIN_D3);
output_low(PIN_D4);
output_low(PIN_D5);
output_low(PIN_D6);
output_low(PIN_D7);
delay_ms(1000);
}
}
|
I dont know if the connection protocol from MPlab ICD3 to EIBot board or my code has a problem.
Any ideas would be highly appreciate.
Fenix |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9247 Location: Greensville,Ontario
|
|
Posted: Thu Jun 06, 2013 7:41 pm |
|
|
I don't use that PIC but some 'general' comments.
1) you don't need to use the set_tris_.... functions, the compiler will automatically handle the registers as required.
2) there's a LOT of external stuff as well as internal peripherals on those I/O pins. Normally you have to disable things like ADC, comparators, PWM, etc. to get simple I/O to work right.
3) I'm assuming you had this board running the preprogrammed software before you tried your code? confirming it's operational ??
4) recheck the configuration fuses for proper speed and oscillator configs.
5) I see it's a 3 volt device, do you have correct load resistors for the LEDs? Again, have you cut/hacked/ removed any peripheral (like motor drivers) from all port D pins?
6) I might try controlling (toggling) only D2 labeled USRLED.
7) try 'nodebug' fuse. If 'debug' is selected some other fuses may get set that you don't know about! If using MPLAB be sure it's in 'release' mode NOT 'debug' before you compile(f10) as program won't run right.
Others, who use that device will know intimate details, aside from from general comments.
hth
jay |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jun 06, 2013 8:54 pm |
|
|
I don't see a crystal on the Eibot board, so I don't know how you get
these fuses and #use delay() frequency:
Quote: | #include <18F46J50.h>
#fuses HSPLL,PLL5,NOWDT,NOPROTECT,DEBUG,NOCPUDIV,NODSBOR,NODSWDT,NOWPFP,NOWPCFG,NOWPDIS,NOFCMEN,NOIESO,RTCOSC_T1
#use delay(clock=31mhz) |
Try this setup instead:
Code: | #include <18F46J50.h>
#fuses INTRC_IO, NOWDT
#use delay(clock=4M) |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19553
|
|
Posted: Fri Jun 07, 2013 2:19 am |
|
|
The default clock fuse setup for this board, is:
INTRC_PLL_IO, T1DIG, PLL1, NOPROTECT, RTCOSC_T1, IOL1WAY, DSBOR, DSWDTOSC_INT, DSWDT2147483648, LPT1OSC
and CLOCK=48MHz
The fuses used for the normal firmware also has XINST enabled, so you can't use the original bootloader to load CCS code. The watchdog is also enabled in the original code.
I had a friend, who was using CCS to write modified code using the normal bootloader sequence, and we had to crack the operating speed, and change the bootloader fuse to use NOXINST to get it to work.
Even without the bootloader, PCM is dead right, the board does not have an oscillator, so the original posted code here hasn't got a hope.....
Best Wishes
Best Wishes |
|
|
oOfenixOo
Joined: 06 Jun 2013 Posts: 3
|
|
Posted: Fri Jun 07, 2013 10:15 am |
|
|
Thank you all for your posts. I really appreciate them.
@temtronic: I've checked all possible conditions but it still doesn't work.
@PCM programmer: I switched to your code too, but nothing happened.
@Ttelmah: I think my problem is the one you mentioned. Is there any chance that you can share the hacking with me so I can program the board?
Fenix |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19553
|
|
Posted: Fri Jun 07, 2013 1:52 pm |
|
|
Seriously, I don't think that is your problem. Using the internal RC, it should work with PCM's code, if the chip was programming correctly. The point about the higher RC clock-rate using the PLL, is it is what is required to use USB.
I haven't any of the stuff we played with, except a few notes about the initial changes.
I'd suggest loading the Eibot circuit diagram, and verifying what pins go to it's programming connector, and which pins they go to on the chip, then comparing this with the suggested ICD-U64 connections.
Best Wishes |
|
|
oOfenixOo
Joined: 06 Jun 2013 Posts: 3
|
|
Posted: Wed Jun 12, 2013 1:43 pm |
|
|
Hi guys,
Today I found out that the code I wrote works when I tried debugger mode in MPLab. When it was in programmer mode, it didn't. So, I am thinking that there's something wrong with the PIC's internal oscillator or oscillator configuration bits. Can anyone post a working internal oscillator configuration here so I can double check with mine?
Thanks,
Fenix |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|