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 CCS Technical Support

Blinking LED On A PIC18F4520
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Geps



Joined: 05 Jul 2010
Posts: 129

View user's profile Send private message

PostPosted: Thu Jul 15, 2010 12:11 pm     Reply with quote

ckielstra did you mange to get it blinking?

I'm away until Monday so won't be able to test anything as it's all at home but I'll post any results first thing Monday morning.
ckielstra



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

View user's profile Send private message

PostPosted: Thu Jul 15, 2010 12:22 pm     Reply with quote

Sorry, I don't have the actual chip so can only test in the Simulator.

Just checked the datasheet a bit more. Table 10-1 makes it clear that digital output pin A1 on this chip is always working and not affected by the analog or comparator module. However it is true that to use the pin A1 as a digital input you would have to disable these two modules.

No clue as to what your problem is. Could be your programmer, that's why I was asking the firmware version number.
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Thu Jul 15, 2010 1:37 pm     Reply with quote

Quote:

I have an external 4MHz resonator connected to the device.

Pls could you describe what type of resonator are you using and its associated components.

Humberto
mkuang



Joined: 14 Dec 2007
Posts: 257

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

PostPosted: Thu Jul 15, 2010 3:16 pm     Reply with quote

ckielstra wrote:
mkuang wrote:
dyeatman wrote:
What about PIN_A1 being defaulted to analog?

setup_adc_(NO_ANALOGS);

You don't need it.

The output_high() and output_low() do that automatically.
the output functions control the TRIS register but do not disable the analog port in my v4.077. And in all the older compiler versions you had to add this line too, so unless something changed at CCS I guess you better still add this line.
You also will have to disable the comparators.

I tried testing your example code. As I don't have v4.087 I tried it in my v4.077. When I added
Code:
setup_adc(NO_ANALOGS);
wrong code was generated. Can you post your list file?

Also post the firmware version for your PicKit2.


Interesting. Whenever I have used portA pins for digital IOs I have never used the line

setup_adc_(NO_ANALOGS);

but to be safe adding it is better I suppose.

nor do I have to disable the comparators. I have used compiler 4.034 or 4.064 (at my new job we use HI-TECH so I don't remember much what I had used before).
jin_evil22



Joined: 25 Jun 2010
Posts: 4

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

PostPosted: Wed Jul 21, 2010 7:58 am     Reply with quote

try this
Code:

#include <18F4520.h>
#fuses XT,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP,
#use delay(clock=200000)


void main()
{
lp1:
   output_high(PIN_A1);
   delay_ms(500);
   output_low(PIN_A1);
   delay_ms(500);
goto lp1
}
mkuang



Joined: 14 Dec 2007
Posts: 257

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

PostPosted: Wed Jul 21, 2010 8:10 am     Reply with quote

What are you using, an external 200khz crystal?
And goto statements are not really good C programming.
bravo9



Joined: 24 Jul 2010
Posts: 3
Location: New Zealand

View user's profile Send private message

Blinking LED
PostPosted: Sun Jul 25, 2010 3:04 am     Reply with quote

I think the PICKIT 2 is a low voltage programmer. Try removing the NO LVP Fuse. I am not sure if you need a high voltage programmer to cleen the chip now. Maybe someone else knows this.

Regards,
Bravo
bravo9



Joined: 24 Jul 2010
Posts: 3
Location: New Zealand

View user's profile Send private message

PostPosted: Sun Jul 25, 2010 7:03 am     Reply with quote

I changed the chip to a 16f877 because I dont have an 18F compiler
& changed the pin to B.1 to avoid the a/d issue & changed the clock to 1000000 ( 1Mhz) & added ; after goto ...... & ran it on Proteus Isis & it works. So it is possible that the chip is not getting all code due to the LVP issue I mentioned above.

Bravo
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jul 25, 2010 10:24 am     Reply with quote

Quote:
I think the PICKIT 2 is a low voltage programmer.

But you can find the answer to this so easily. Type this into Google
to find a document on the Microchip site related to the question:
Quote:

site:microchip.com "Pickit 2" "programming voltage"


That gets you the Pickit 2 User's Guide:
http://ww1.microchip.com/downloads/en/DeviceDoc/PICkit2%20User%20Guide%2051553a.pdf

Now search the User's Guide for the name of the programming voltage
pin, which is Vpp. You will find this statement:
Quote:

3.2 ISOLATE VPP/MCLR/PORT PIN
When VPP voltage is applied, the application circuit needs to take into
consideration that the typical VPP voltage is +12V.

So it's not a low voltage programmer. You don't use the LVP fuse.
You must use NOLVP.
bravo9



Joined: 24 Jul 2010
Posts: 3
Location: New Zealand

View user's profile Send private message

PostPosted: Mon Jul 26, 2010 5:57 am     Reply with quote

PCM Programmer,
Thanks for this. I had trouble with an old EPIC programmer when its voltage was 15v so I increased it to 16v & the problem went away, as suggested by someone on the Proton forum. I assumed 12v would be low.
Geps



Joined: 05 Jul 2010
Posts: 129

View user's profile Send private message

PostPosted: Wed Aug 04, 2010 2:42 am     Reply with quote

Just as a follow up to this. I've been using the PIC18 development board from CCS which uses a PIC18F4520. The code I was using worked fine. I've since rebuilt the circuit with the old chips and rewritten code, and it seems to be working nicely now.

All voltages and clock signals are the same as before on the pins so not quite too sure how/what is different.

Thanks for all the help.
Ttelmah



Joined: 11 Mar 2010
Posts: 20159

View user's profile Send private message

PostPosted: Wed Aug 04, 2010 3:01 am     Reply with quote

bravo9 wrote:
PCM Programmer,
Thanks for this. I had trouble with an old EPIC programmer when its voltage was 15v so I increased it to 16v & the problem went away, as suggested by someone on the Proton forum. I assumed 12v would be low.


Don't confuse the unit's supply voltage, with the programming voltage.
On the old programmer, the supply, generates 12v, using a 'linear' regulator. This needs a few volts 'margin' to work correctly (depends on the chip involved, but typically 3 to 4v), so with a 15v supply, was 'borderline' to give a reliable 12v. Later units usually generate the 12v, using a small 'boost' switching regulator, and may well run off only 5v, but still program the PIC at 12v....

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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