PDA

View Full Version : StartUSB board from MikroE



Fredrick
- 1st June 2014, 12:40
Hi

I have a StartUSB board from MikroE http://www.mikroe.com/startusb/pic/ that I been trying to program with a simple PBP program via the bootloader but there is someting wrong.

The pauses in the program is much shorter than 1000ms, I have tried to change the config FOSC settings but nothing helps.

Any idés of what to do next?



DEFINE OSC 8

include "C:\ODIN\PIC\INCLUDES\ALLDIGITAL.pbp"
asm
__CONFIG _CONFIG1L, _PLLDIV_2_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_1_1L
__CONFIG _CONFIG1H, _FOSC_XT_XT_1H
__CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
__CONFIG _CONFIG3H, _PBADEN_OFF_3H
__CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L & 0DFh

endasm

Main:

pause 1000
toggle PORTA.1
pause 1000

Goto Main

Demon
- 1st June 2014, 12:42
You will pause for 2000 if you keep the 2nd PAUSE.

Robert

Fredrick
- 1st June 2014, 12:51
Yes, but the LED on PORTA.1 is blinking faster than that.

If I set PAUSE 5000 the LED blinks around every second so there must be something wrong with the speed of the PIC.

Demon
- 1st June 2014, 14:02
Then there most likely is something wrong with CONFIG1 settings.

Robert


Edit: Last time I used USB on an 18F2550, I think I had to use 48 MHz.

If you have an 8 MHz oscillator, then CONFIG1 has to be set accordingly.

Demon
- 1st June 2014, 14:25
Haven't found a thread with 18F2550 with 8MHz crystal and USB (I'm assuming the end goal is to use USB feature).

Some reading on PLL:

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

Robert

Demon
- 1st June 2014, 14:29
Just to clarify, DEFINE OSC setting does not have to match external oscillator. By adjusting CONFIG1 you can use a 8MHz crystal and have the PIC run at 48MHz for USB.

Robert

Fredrick
- 1st June 2014, 14:42
I only use the USB for loading the program. so I don´t care if the USB not working in my PBP program.


EDIT.
Maybe the bootloader don´t allows me to change Configs from my PBP program?
I changed the DEFINE OSC 8 to DEFINE OSC 48 and now the pause times is OK and the Serin/Serout also works so I assume that I with this bootloader I can only run my PBP program at 48Mhz?

EarlyBird2
- 1st June 2014, 17:59
You are dealing with a PLL chip read this post.

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

look at your config section and you will find the settings for pll.

for more info search for pll and if you understand it you can possibly explain it to me.

Obviously Henrik understands it! amongst others.

Demon
- 1st June 2014, 22:05
The board is designed for USB applications, hence the need for 48MHz.

It's "possible" the bootloader overrides the CONFIGs, just like we can with a programmer (never used bootloader).

Robert

HenrikOlsson
- 2nd June 2014, 06:12
Maybe the bootloader don´t allows me to change Configs from my PBP program?

That's correct. It's the bootloader that contains the CONFIG. When you download your PBP program using the bootloader then the CONFIG contained in your "download" will not be used. Exactly how it works may differ from bootloader to bootloader but basically the CONFIG is part of the bootloader and the bootloader protects itself from being overwritten.

Had you been allowed to change the CONFIG via the bootloader then you could possibly set it to such a state the bootloader, which of course is just another piece of code in the PIC, wouldn't run as intended and you end up with a bricked PIC needing to be reprogrammed with a device programmer.

/Henrik.

EarlyBird2
- 2nd June 2014, 06:37
I always used a bootloader because I used Rentron boards and have I always wondered why others coded configs. Now I know! Thanks guys one less thing to think about.