Hello,
I was wondering if someone could suggest why this code below doesn't work to change the oscillator speed of the Internal Oscillator while the program is running but the other code block below does work? Another thing I was pondering is, shouldn't I be setting bit 0 of the OSCCON register to 1? The datasheet for the 16f887 says this about bit 0:
1 = Internal oscillator is used for system clock
0 = Clock source defined by FOSC<2:0> of the CONFIG1 register.
Code:'this doesn't work IF Push_Button = Is_Pressed THEN IF OSCCON = %01100000 THEN OSCCON = %01110000 ELSE OSCCON = %01100000 ENDIF WHILE Push_Button = Is_Pressed PORTD = %10000001 ' Show that button press has stopped the code here WEND ENDIFThanksCode:'this works IF Push_Button = Is_Pressed THEN IF B = 0 THEN B = 1 ELSE B = 0 ENDIF WHILE Push_Button = Is_Pressed PORTD = %10000001 ' Show that button press has stopped the code here WEND ENDIF IF B = 0 THEN OSCCON = %01110000 ' 8 MHz IF B = 1 THEN OSCCON = %01100000 ' 4 MHz
jessey




Bookmarks