| View previous topic :: View next topic |
| Author |
Message |
Geps
Joined: 05 Jul 2010 Posts: 129
|
|
Posted: Thu Jul 15, 2010 12:11 pm |
|
|
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
|
|
Posted: Thu Jul 15, 2010 12:22 pm |
|
|
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
|
|
Posted: Thu Jul 15, 2010 1:37 pm |
|
|
| 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
|
|
Posted: Thu Jul 15, 2010 3:16 pm |
|
|
| 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
|
|
Posted: Wed Jul 21, 2010 7:58 am |
|
|
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
|
|
Posted: Wed Jul 21, 2010 8:10 am |
|
|
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
|
| Blinking LED |
Posted: Sun Jul 25, 2010 3:04 am |
|
|
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
|
|
Posted: Sun Jul 25, 2010 7:03 am |
|
|
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
|
|
Posted: Sun Jul 25, 2010 10:24 am |
|
|
| 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
|
|
Posted: Mon Jul 26, 2010 5:57 am |
|
|
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
|
|
Posted: Wed Aug 04, 2010 2:42 am |
|
|
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
|
|
Posted: Wed Aug 04, 2010 3:01 am |
|
|
| 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 |
|
 |
|