Hi,
I was experimenting with 18f452 pic and a simple led tutorial. It appears that the RC oscillator frequency is about 0.1Hz, can I modify it somehow?
Basically, the code for the blinking is present below, it doesn't have any delays:
#include <p18f452.inc>
__CONFIG _CONFIG1H, _OSCS_ON_1H & _RC_OSC_1H ; External Clock on OSC1 & OSC2
__CONFIG _CONFIG2L, _BOR_ON_2L & _BORV_20_2L & _PWRT_OFF_2L ; Brown out reset on at 2.0V, no power-up timer
__CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H ; watchdog off, postscaler count to 128
__CONFIG _CONFIG3H, _CCP2MX_ON_3H ; CCP2 pin Mux enabled. What is this?
__CONFIG _CONFIG4L, _STVR_ON_4L & _LVP_ON_4L & _DEBUG_OFF_4L ; Stack under/overflow reset on, LVP on, debug off
__CONFIG _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L & _CP2_OFF_5L & _CP3_OFF_5L ; all protection off
__CONFIG _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H
__CONFIG _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L & _WRT2_OFF_6L & _WRT3_OFF_6L
__CONFIG _CONFIG6H, _WRTC_OFF_6H & _WRTB_OFF_6H & _WRTD_OFF_6H
__CONFIG _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L & _EBTR2_OFF_7L & _EBTR3_OFF_7L
__CONFIG _CONFIG7H, _EBTRB_OFF_7H
org 0x0000
COUNT1 equ 0x01
COUNT2 equ 0x02
clrf TRISD ; set all bits in TRISD to zero.
Main
bsf PORTD, RD1 ; set bit RD1 in the PORTD register
bcf PORTD, RD1 ; clear bit RD1 in the PORTD register
goto Main
END
Using this code, the led is on for about 4 seconds, and then off for like 10 seconds. I am using simple RC oscillator (R & C, R to vdd, C to gnd) as presented in the datasheet. The R=10k, and C=100uF (25V).
What should I change to increase the oscillation frequency?
I was experimenting with 18f452 pic and a simple led tutorial. It appears that the RC oscillator frequency is about 0.1Hz, can I modify it somehow?
Basically, the code for the blinking is present below, it doesn't have any delays:
#include <p18f452.inc>
__CONFIG _CONFIG1H, _OSCS_ON_1H & _RC_OSC_1H ; External Clock on OSC1 & OSC2
__CONFIG _CONFIG2L, _BOR_ON_2L & _BORV_20_2L & _PWRT_OFF_2L ; Brown out reset on at 2.0V, no power-up timer
__CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H ; watchdog off, postscaler count to 128
__CONFIG _CONFIG3H, _CCP2MX_ON_3H ; CCP2 pin Mux enabled. What is this?
__CONFIG _CONFIG4L, _STVR_ON_4L & _LVP_ON_4L & _DEBUG_OFF_4L ; Stack under/overflow reset on, LVP on, debug off
__CONFIG _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L & _CP2_OFF_5L & _CP3_OFF_5L ; all protection off
__CONFIG _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H
__CONFIG _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L & _WRT2_OFF_6L & _WRT3_OFF_6L
__CONFIG _CONFIG6H, _WRTC_OFF_6H & _WRTB_OFF_6H & _WRTD_OFF_6H
__CONFIG _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L & _EBTR2_OFF_7L & _EBTR3_OFF_7L
__CONFIG _CONFIG7H, _EBTRB_OFF_7H
org 0x0000
COUNT1 equ 0x01
COUNT2 equ 0x02
clrf TRISD ; set all bits in TRISD to zero.
Main
bsf PORTD, RD1 ; set bit RD1 in the PORTD register
bcf PORTD, RD1 ; clear bit RD1 in the PORTD register
goto Main
END
Using this code, the led is on for about 4 seconds, and then off for like 10 seconds. I am using simple RC oscillator (R & C, R to vdd, C to gnd) as presented in the datasheet. The R=10k, and C=100uF (25V).
What should I change to increase the oscillation frequency?