yeah... it run but the default OSC speed is set to 32KHz
just add those
at the top of your code.Code:OSCCON= %01100000 ' configure internal OSC @ 4MHZ While OSCCON.2=0 : wend ' wait until OSC is stable
For the configuration bits, it's usual and recommended to set them in your code, have a look at the following...
http://www.picbasic.co.uk/forum/showthread.php?t=543
and here's a short example for a 18F2431, as inspiration source
Now if you want to switch to the external OSC, use...Code:' ' Pic Configuration ' ================= ASM __CONFIG _CONFIG1H, _OSC_IRCIO_1H & _FCMEN_OFF_1H & _IESO_OFF_1H __CONFIG _CONFIG2L, _PWRTEN_ON_2L & _BOREN_ON_2L & _BORV_45_2L __CONFIG _CONFIG2H, _WDTEN_OFF_2H & _WINEN_OFF_2H __CONFIG _CONFIG3L, _T1OSCMX_OFF_3L & _HPOL_LOW_3L & _LPOL_HIGH_3L & _PWMPIN_OFF_3L __CONFIG _CONFIG3H, _MCLRE_ON_3H __CONFIG _CONFIG4L, _LVP_OFF_4L & _DEBUG_OFF_4L ENDASM DEFINE OSC 4
and remove the OSCCON & WHILE : WEND linesCode:ASM __CONFIG _CONFIG1H, _OSC_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H __CONFIG _CONFIG2L, _PWRTEN_ON_2L & _BOREN_ON_2L & _BORV_45_2L __CONFIG _CONFIG2H, _WDTEN_OFF_2H & _WINEN_OFF_2H __CONFIG _CONFIG3L, _T1OSCMX_OFF_3L & _HPOL_LOW_3L & _LPOL_HIGH_3L & _PWMPIN_OFF_3L __CONFIG _CONFIG3H, _MCLRE_ON_3H __CONFIG _CONFIG4L, _LVP_OFF_4L & _DEBUG_OFF_4L ENDASM DEFINE OSC 8






Bookmarks