PDA

View Full Version : PIC18F4620 Programming problem



JavPar
- 5th December 2008, 04:29
Hello everyone. I am having a problem with PBP where I am not able to program my PIC18F4620. I know everything is OK with my PIC and the circuit as I can use another program called PIC18 Simulator IDE to program it and everything works fine. I use a bootloader but even without the booloader it just doesn't work when I try to program it with PBP. I am thinking that I must have something not configure properly on my PBP or something. I'll appreciate if someone can help with this as I have already spent three days on this and can't locate the problem. Following my code:

'********************
DEFINE LOADER_USED 1 'Bootloader Used
@ __CONFIG _CONFIG1H, _OSC_HS_1H
DEFINE OSC 8
loop:
Serout2 PORTB.7,16468,["Testing123"] 'For PC
High PORTA.0
Low PORTD.0
pause 1000
Low PORTA.0
High PORTD.0
pause 1000
Goto loop
'*********************


Thanks in advance.

Javier.

fronkensteen
- 5th December 2008, 04:56
Hello everyone. I am having a problem with PBP where I am not able to program my PIC18F4620. I know everything is OK with my PIC and the circuit as I can use another program called PIC18 Simulator IDE to program it and everything works fine. I use a bootloader but even without the booloader it just doesn't work when I try to program it with PBP. I am thinking that I must have something not configure properly on my PBP or something. I'll appreciate if someone can help with this as I have already spent three days on this and can't locate the problem. Following my code:

Saw this one earlier today

http://www.picbasic.co.uk/forum/showthread.php?t=10214

mackrackit
- 5th December 2008, 10:55
Welcome to the forum.

Here is how it works with people trying to sell books and simulators.

I made an LED blink on a 16F84...Now I am expert with MiroChips!
I will write a book.

I downloaded a compiler to use... made LED blink..Expert again!
I will make a Simulator.

It is obvious the person that made the simulator does not know PIC chips or they would have had an error show when you are trying to use an ADC pin as an output before it has been set up for that function.

Stop wasting your time with that crap and spend the same time reading the data sheet and the manual of the parts/ compiler you are using.

This thread should get you going.
http://www.picbasic.co.uk/forum/showthread.php?t=561
It talks about setting the ADC to digital.

JavPar
- 5th December 2008, 15:06
Thank you for the links, but they do not help me. Maybe I didn't explain myself clearly. I only use the simulator to write the code which I burn into the chip which works 100% in my real life circuit. I use the melabs U2 programmer. Regarding reading the datasheet, I have it and I always refer to it when working on my chip.

I am trying to NOT use the simulator program anymore so I can only use PBP. But it is not working.

Javier.

mackrackit
- 5th December 2008, 15:26
I only use the simulator to write the code which I burn into the chip which works 100% in my real life circuit.


I am trying to NOT use the simulator program anymore so I can only use PBP. But it is not working.


I am not sure what is not working.

fronkensteen
- 5th December 2008, 15:35
Maybe I didn't explain myself clearly.
There's no maybe about it.


Regarding reading the datasheet, I have it and I always refer to it when working on my chip.
And if you actually did have and/or use the datasheet, you would know that PortA.0 (and many other pin) function as analog inputs upon reset and will not function as digital outputs without further configuration.


I am trying to NOT use the simulator program anymore so I can only use PBP. But it is not working.
Huh?

JavPar
- 5th December 2008, 15:52
I really appreciate you guys trying to help. The code that you see on my previous post makes the leds blinks, both porta.0 and portd.0. I do not know about other pics, but on the 18F4620 the port is digital as per the datasheet. If you want to use for ADC, then you must specify it on code. It is on chapter 19 of the datasheet. Again, the code works 100% when I use the Basic editor on the simulator or if I use assembler. I only use the basic editor of the simulator to write the code and create the hex file to then burn it on the chip.

My point is, when I use MicroCode Studio to write code and I want to pass it to my chip, the code does not work. In other words, the leds do not blink. I think there might be something wrong or I am doing something wrong on my code.

mackrackit
- 5th December 2008, 16:03
but on the 18F4620 the port is digital as per the datasheet. If you want to use for ADC, then you must specify it on code.

That is the part you have backwards. You have to make the pins digital.

So... refer to the link I gave you and try


ADCON1=15

Keep reading chapter 19 and look at
REGISTER 19-2: ADCON1: A/D CONTROL REGISTER 1

JavPar
- 5th December 2008, 16:14
I could think that it is why led on port a is not turning on, but what about led on port d.

I have to leave to work now but I will defenetaly try your suggestion when I get back tonight.

mackrackit
- 5th December 2008, 16:30
Looking at your code again. The
DEFINE OSC 8
leads me to believe you are using the internal OSC. If so try this


@ __CONFIG _CONFIG1H, _OSC_INTIO67_1H
@ __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
@ __CONFIG _CONFIG3H, _PBADEN_OFF_3H
@ __CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L

in place of you config line.

JavPar
- 6th December 2008, 02:55
Hey guys, tried both suggestions and still not working. My code looks like this:

DEFINE LOADER_USED 1 'Bootloader Used
'@ __CONFIG _CONFIG1H, _OSC_HS_1H
@ __CONFIG _CONFIG1H, _OSC_INTIO67_1H
@ __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
@ __CONFIG _CONFIG3H, _PBADEN_OFF_3H
@ __CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
ADCON1=15
DEFINE OSC 8
loop:
Serout2 PORTB.7,16468,["Testing123"] 'For PC
High PORTA.0
Low PORTD.0
pause 1000
Low PORTA.0
High PORTD.0
pause 1000
Goto loop

I still think that the problem could reside in MicroCode Studio. I will continue working on it tonight.

fronkensteen
- 6th December 2008, 03:04
Decrease the pauses to pause 1 and see what happens.

JavPar
- 6th December 2008, 03:09
Changed the pauses to 1, but nothing. No change.

fronkensteen
- 6th December 2008, 03:48
Changed the pauses to 1, but nothing. No change.

How long did you let it run?

b1arrk5
- 6th December 2008, 03:55
Hi Javier,
Which programmer are you using when you don't use the bootloader? Did you set it up in Microcode Studio? You may have to set the configuration settings for your programmer manually, or you may have to change a setting to allow the programmer to read from your file first.

Good Luck,

Jerry

JavPar
- 6th December 2008, 04:21
OK, problem solved. On my MicroCode Studio Plus it was showing the In Circuit Debug (ICD) toolbar. I was pressing ICD compile and program button instead of the normal compile and debug button. Now everything is working 100%.

Thanks to all of you for your kind help.

Javier.