CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

my PIC18F4525 won't work!!!

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
jamesjl



Joined: 22 Sep 2003
Posts: 52
Location: UK

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

my PIC18F4525 won't work!!!
PostPosted: Fri Apr 08, 2005 5:13 am     Reply with quote

Hi all,

PIC 18F4525 and PIC16F874A
PCWH 3.222

I have replaced a PIC16F874A with a PIC18F4525, but I can't program it.

I notice that the PGM pin has moved from pin 11 on the 874A to pin 15 on the 4525. I have move this on my development PCB but still the chip won't program. When I program the PIC the programmer pops up the verification results box with all addresses as FF, and not what was expected.

I even created a demo app from scratch to make sure that the fuses were set up correctly.

Code:

#include <18F4525.h>
#device adc=8
#fuses NOWDT,WDT128,XT, NOPROTECT, IESO, BROWNOUT, BORV21, PUT, CPD, STVREN, NODEBUG, NOLVP, NOWRT, NOWRTD, NOEBTR, NOCPB, NOEBTRB, NOWRTC, NOWRTB, FCMEN, XINST, NOPBADEN, LPT1OSC, MCLR
#use delay(clock=4000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=RS485,enable=PIN_C5,errors)


and

Code:

#include "Demo.h"
#int_TIMER0
TIMER0_isr()
{
}
#int_TIMER1
TIMER1_isr()
{
}

#int_TIMER2
TIMER2_isr()
{

}

#int_TIMER3
TIMER3_isr()
{

}

#int_RDA
RDA_isr()
{

}



void main()
{

   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF|ADC_TAD_MUL_0);
   setup_psp(PSP_DISABLED);
   setup_spi(FALSE);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_8|RTCC_8_bit);
   setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
   setup_timer_2(T2_DIV_BY_4,16,1);
   setup_timer_3(T3_INTERNAL|T3_DIV_BY_4);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
/*
   enable_interrupts(INT_TIMER0);
   enable_interrupts(INT_TIMER1);
   enable_interrupts(INT_TIMER2);
   enable_interrupts(INT_TIMER3);
   enable_interrupts(INT_RDA);
   enable_interrupts(GLOBAL);
*/
   
   while(TRUE)
   {
      output_high(PIN_D0);
      delay_ms(100);
      output_low(PIN_D0);
      delay_ms(100);
   }

}


I disabled the interrupts so that they won't fire as I have no ISR code for this demo.

Does anyone have and ideas what could be going wrong?

Thanks,

Jason.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Apr 08, 2005 6:25 am     Reply with quote

Well, you have NOLVP specified in your fuses so most likely you are not using the PGM pin. It is for low programming mode. The fact that you said it is on pin 15 makes me wonder though. It is on pin 15 of the QFN and TQFP packages and not on the 40 dip. That being said, if you soldered this chip yourself, I would check all those connections.
jamesjl



Joined: 22 Sep 2003
Posts: 52
Location: UK

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Fri Apr 08, 2005 6:34 am     Reply with quote

Mark,

I've built three units with the 18F4525 now and none of them work. I have tried numerous configuration settings and each time I get nothing. As you can see I have dropped the OSC down to 4MHz to see if that made a difference. I have even tried the internal OSC. Still nothing. The oscillator is not running once the programming has been completed.

I've checked the soldering and device orientation and they all seem to be OK. I am using the TQFP device and have moved the PGM from my 16F874A pin 11 to pin 15 of my 18F4525.

Any other thoughts? I thought that this would be an easier route than developing a new PCB for an 18F6620!!

Thanks,

Jason.
jamesjl



Joined: 22 Sep 2003
Posts: 52
Location: UK

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Fri Apr 08, 2005 6:36 am     Reply with quote

When dropping to the 4MHz crystal I changed to the XT option in #fuses, not HS.

Code:
#include <18F4525.h>
#device adc=8
#fuses NOWDT,WDT128,XT, NOPROTECT, IESO, BROWNOUT, BORV21, PUT, CPD, STVREN, NODEBUG, LVP, NOWRT, NOWRTD, NOEBTR, NOCPB, NOEBTRB, NOWRTC, NOWRTB, FCMEN, XINST, NOPBADEN, LPT1OSC, MCLR
#use delay(clock=4000000)


Thanks,

Jason.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Apr 08, 2005 6:57 am     Reply with quote

The OSC doesn't matter for programming. It doesn't even matter what you are really even programming in there if the verification fails. Yeah, the code might not run but it should verify. All you need to successfully program the chip are the following connections: Vpp, PGD,PGC,Both of the VDD's and VSS's.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Fri Apr 08, 2005 7:23 am     Reply with quote

I do agree with Mark. Your problem is not in the software you are trying to program but is hardware or programmer related.

Which programmer do you use?
If using the ICD2, which version of MPLAB are you using?

If using the ICD2, are you trying to program with the ICD2 in debugger or in programmer mode? ICD2 debugger support for the 18F4525 is still Beta in MPLAB v7.00, so try if it works in programmer mode.
jamesjl



Joined: 22 Sep 2003
Posts: 52
Location: UK

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Fri Apr 08, 2005 7:38 am     Reply with quote

Gents,

Got it working but don't really understand why. Please can you help.

Code:
#include <18F4525.h>
#device adc=8
#use delay(clock=4000000)
#fuses NOWDT,WDT128, XT, NOPROTECT, PUT, NOLVP ,MCLR, IESO, BROWNOUT, BORV21, DEBUG, NOCPD

works great
Code:
#include <18F4525.h>
#device adc=8
#use delay(clock=4000000)
#fuses NOWDT,WDT128, XT, NOPROTECT, PUT, LVP ,MCLR, IESO, BROWNOUT, BORV21, DEBUG, NOCPD

does work at all. And my main program is only:
Code:
#include "Demo.h"

void main()
{
   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF|ADC_TAD_MUL_0);
   setup_psp(PSP_DISABLED);
   setup_spi(FALSE);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_8|RTCC_8_bit);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_timer_3(T3_DISABLED);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);

   while(TRUE)
   {
      output_D(0xFF);
      delay_ms(100);
      output_D(0x00);
      delay_ms(100);
   }
   while(TRUE);
}

The only difference seems to be between LVP and NOLVP. Why can't I use the low voltage programming option. I don't need to, but what is the difference?

Kind regards,

Jason.

P.S. Where can I find exactly what the other fuses do?
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Apr 08, 2005 7:40 am     Reply with quote

Depends on what you are doing with the LVP pin. If it is unused for anything else, it should be okay. If there is a signal on it, this will put the device into programming mode and your code will not work.

What was the problem keeping the device from programming correctly?
jamesjl



Joined: 22 Sep 2003
Posts: 52
Location: UK

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Fri Apr 08, 2005 8:13 am     Reply with quote

Mark,

that was the only porblem. Pin RB5 is not being used for anything else. I am using the ICD-U40 with the latest firmware installed. When I changed the #fuses line everything worked OK. When I changed it back to LVP it failed.

It's a mystery.

Many thanks,

Jason.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Apr 08, 2005 8:17 am     Reply with quote

Your orginal post stated you were using NOLVP and got verification errors?? So are you now saying that this is incorrect? Are you saying that you don't get any verification errors now but the code works with NOLVP but not with LVP?
jamesjl



Joined: 22 Sep 2003
Posts: 52
Location: UK

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Fri Apr 08, 2005 8:46 am     Reply with quote

Mark,

actually yes, you are correct. It's amazing how quickly you forget stuff when things start working right Embarassed . I also upgraded my ICD to the latest version. That may have stopped the verification errors.

I created a new project using the wizard and didn't get any verification errors when I programmed the device, and I haven't modified my hardware at all. Only a firmware upgrade on the programmer.

However, with the fuses set as
Code:
#fuses NOWDT,WDT128,XT, NOPROTECT, IESO, BROWNOUT, BORV21, NOPUT, NOCPD, STVREN, NODEBUG, NOLVP, NOWRT, NOWRTD, NOEBTR, NOCPB, NOEBTRB, NOWRTC, NOWRTB, FCMEN, XINST, NOPBADEN, LPT1OSC, MCLR


I get a period of 32.8us with a 4MHz clock, not 200 ms as set by

Code:
   while(true)
   {
      output_d(0xff);
      delay_ms(100);
      output_d(0x00);
      delay_ms(100);
   }


which works correctly get when I use
Code:
#fuses NOWDT,WDT128,XT, NOPROTECT, IESO, BROWNOUT, BORV21, NOPUT, NOCPD, STVREN, NODEBUG, NOLVP


Any thoughts?

Many thanks,

Jason.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Fri Apr 08, 2005 9:58 am     Reply with quote

Quote:
P.S. Where can I find exactly what the other fuses do?
Check the file fuses.txt in your compiler directory. More details on the fuses can be found in your processor manual, most options in the chapter "Special Functions of the CPU".
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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