PDA

View Full Version : PicBasic, PicKit2 and configuration...



RuudNL
- 26th February 2012, 13:30
At the moment I am pulling my hair out...
I am using a PIC18F14K50. The program is made in PicBasic 3.
I am using a 12 MHz crystal, because I need USB support. (PLL Osc. x 4)
In the past I always could set the configuration bits in my 'good old' Epic (parallel port) programmer.
Because the PIC18F14K50 needs different programming voltages, I recently bought the PicKit2.
But as far as I see, there is no way of setting the configuration word...
Is there a way to include the settings in the source (.pbp) file?
Or how can I tell the PIC18F14K50 that it has to use an external crystal in the PLL osc. x 4 mode?
I am completely lost! Any help is appreciated!!!

ScaleRobotics
- 26th February 2012, 14:41
Configs are a pain. Here is one that should work for you. PBP3 makes it easier, once the configs are right. Just put this into your code.



#config ; 18F13K50/14K50 Only 12mhz crystal can be used for USB ;
__CONFIG _CONFIG1L, _CPUDIV_NOCLKDIV_1L & _USBDIV_OFF_1L ;
__CONFIG _CONFIG1H, _FOSC_HS_1H & _PLLEN_ON_1H & _PCLKEN_ON_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
#endconfig

RuudNL
- 26th February 2012, 15:46
Thanks a lot! I will try that. :distracted:
In the meantime I found a (very unelegant!) solution:

I compile the source code in the PBP compiler.
After that I start my 'good old' Epic Parallel programmer and load the hex-file.
I can change the configuration settings in the Epic software and save the hex-file again.
After that, I program the (modified) hex-file with the PicKit2 programmer. (Because of the lower programming voltage.)
This works... But not a very nice solution!

RuudNL
- 26th February 2012, 16:15
Here is one that should work for you. PBP3 makes it easier, once the configs are right. Just put this into your code.
It was a nice try, but it doesn't work. The crystal is not oscillating. (I looked with a scope.)
Also the PicKit2 was complaining about incorrect configuration values.
However, most of the problems are solved now, since I can change the configuration with the Epic programmer software.
One has to improvise sometimes...

ScaleRobotics
- 26th February 2012, 16:30
Interesting.

Actually, it wasn't a try. It is a configuration known to work. http://www.picbasic.co.uk/forum/showthread.php?t=5418&page=2&p=80434#post80434
And, I have used it with (with a Pickit2) with success. The only complaining that the pickit should be doing, it saying that your are not setting each of the config.

What did you change the configs to, to make it work for you?

ScaleRobotics
- 26th February 2012, 17:00
Well,

This works for sure in PBP3 and Pickit2 (just used it). Needs Xinst off and LVP off. Sorry.


#config ; 18F13K50/14K50 Only 12mhz crystal can be used for USB
__CONFIG _CONFIG1L, _CPUDIV_NOCLKDIV_1L & _USBDIV_OFF_1L
__CONFIG _CONFIG1H, _FOSC_HS_1H & _PLLEN_ON_1H & _PCLKEN_ON_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
__CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _BBSIZ_OFF_4L & _XINST_OFF_4L
#endconfig

RuudNL
- 26th February 2012, 17:15
Great! I'll try this later this evening.
Thanks again for your help!!!

RuudNL
- 26th February 2012, 17:21
Just couldn't wait.... It works!!!
Problem solved.