News:

;) This forum is the property of Proton software developers

Main Menu

OSCTUN question

Started by RGV250, Today at 12:40 PM

Previous topic - Next topic

RGV250

Hi,
First time I have used OSCTUN so this may be a stupid question. Does it only work on the base frequency.

This code works IE the serial output is OK.
Device = 24HJ128GP502
Declare Xtal = 8.01
' Configure for internal 8.01MHz oscillator with PLL
' OSC pins are general purpose I/O
'
    Config FBS = BWRP_WRPROTECT_OFF, BSS_NO_FLASH, BSS_NO_BOOT_CODE
    Config FSS = SWRP_WRPROTECT_OFF, SSS_NO_FLASH, RSS_NO_SEC_RAM
    Config FGS = GWRP_OFF, GCP_OFF
    Config FOSCSEL = FNOSC_FRCPLL, IESO_OFF
    Config FOSC = POSCMD_NONE, OSCIOFNC_ON, IOL1WAY_OFF, FCKSM_CSDCMD
    Config FWDT = WDTPOST_PS256, WINDIS_OFF, FWDTEN_OFF
    Config FPOR = FPWRT_PWR128, ALTI2C_OFF
    Config FICD = ICS_PGD1, JTAGEN_OFF

    OSCTUN = $17                                ' Set to give 8.01mhz frequency       
    PLL_Setup(4, 2, 2, $0300)                   ' Configure the Oscillator to operate the device at 8.01MHz
'------------------------------------------------
' USART1 declares
' Default BAUD rate for the MCP2200 on the Microstick Plus board
    Declare Hserial_Baud = 19200     
         
    Declare HRSOut1_Pin = PORTB.10              ' Select which pin is to be used for TX with USART1   
    PPS_Output(cOut_Pin_RP10, cOut_Fn_U1TX)     ' Make Pin RB10 U1TX

    Dim seconds As Word
    seconds = 0
'------------------------------------------------   

Main:

    Do                                          ' Create a loop
    HRSOut1Ln "Testing 8.01mhz xtal. ", Dec seconds       
    DelayMS 1000
    Inc seconds
    Loop                                        ' Do it forever


If I change it to try to get 80.1mhz it gives garbage out. If I leave the OSCTUN out and set it for xtal = 73.7 it works fine.
Device = 24HJ128GP502
Declare Xtal = 80.1
' Configure for internal 80.1MHz oscillator with PLL
' OSC pins are general purpose I/O
'
    Config FBS = BWRP_WRPROTECT_OFF, BSS_NO_FLASH, BSS_NO_BOOT_CODE
    Config FSS = SWRP_WRPROTECT_OFF, SSS_NO_FLASH, RSS_NO_SEC_RAM
    Config FGS = GWRP_OFF, GCP_OFF
    Config FOSCSEL = FNOSC_FRCPLL, IESO_OFF
    Config FOSC = POSCMD_NONE, OSCIOFNC_ON, IOL1WAY_OFF, FCKSM_CSDCMD
    Config FWDT = WDTPOST_PS256, WINDIS_OFF, FWDTEN_OFF
    Config FPOR = FPWRT_PWR128, ALTI2C_OFF
    Config FICD = ICS_PGD1, JTAGEN_OFF

    OSCTUN = $17                                ' Set to give 8.01mhz frequency       
    PLL_Setup(43, 2, 2, $0300)                   ' Configure the Oscillator to operate the device at 80.1MHz
'------------------------------------------------
' USART1 declares
' Default BAUD rate for the MCP2200 on the Microstick Plus board
    Declare Hserial_Baud = 19200     
         
    Declare HRSOut1_Pin = PORTB.10              ' Select which pin is to be used for TX with USART1   
    PPS_Output(cOut_Pin_RP10, cOut_Fn_U1TX)     ' Make Pin RB10 U1TX

    Dim seconds As Word
    seconds = 0
'------------------------------------------------   

Main:

    Do                                          ' Create a loop
    HRSOut1Ln "Testing 80.1mhz xtal. ", Dec seconds       
    DelayMS 1000
    Inc seconds
    Loop                                        ' Do it forever

Regards,
Bob

RGV250

Oops, a senior moment.
I used the modified spreadsheet from Trastikata and it works.
https://protoncompiler.com/index.php/topic,3341.msg24449/topicseen.html#new

It needed 40 instead of 43.
PLL_Setup(40, 2, 2, $0300)        ' Configure the Oscillator to operate the device at 80.1MHz

Bob