News:

Let's find out together what makes a PIC Tick!

Main Menu

Fosc settings dsPic33

Started by basparky, Jul 20, 2021, 08:21 PM

Previous topic - Next topic

basparky

Hi all,

I have a question about the Fos settings for a dsPic. The Datasheet says:
Max CPU Speed (MHz) 70
CPU Speed (MIPS/DMIPS) 70

Are the following PLL settings correct in this case to get the highest speed for this device? I'm struggling to get things clear at the moment:( This sets me back to the beginning...

Device = 33EP256GP502
Config FICD = ICS_PGD1, JTAGEN_ON
Config FPOR = ALTI2C1_OFF, ALTI2C2_OFF, WDTWIN_WIN25
Config FWDT = FWDTEN_ON, PLLKEN_ON, WDTPOST_PS32768, WDTPRE_PR128, WINDIS_OFF
Config Fosc = FCKSM_CSDCMD, IOL1WAY_ON, OSCIOFNC_OFF, POSCMD_HS
Config FOSCSEL = FNOSC_PRIPLL, IESO_ON
Config FGS = GCP_OFF, GWRP_OFF
Declare Xtal = 70
;-------------------------------------------------------------------------------
'Fosc = (10 * 28) / (2 * 2) = 70MHz (70 MIPS)
PLL_Setup(28,2,2,$0300)


Does anyone know a faster dspic supported by Proton and with all common features as we know them today?

normnet

Quote from: basparky on Jul 20, 2021, 08:21 PMDoes anyone know a faster dspic supported by Proton and with all common features as we know them today?

Although not a dspic the 24EP128GP202 for example is 140.03 MHz.  I can provide the fuse settings if any interest.


Personally I am looking for the settings for one of the newly supported 200 MHz pics although they are surface mount.  Say a 28 SSOP as I have a DIP adapter on hand.

Norm

tumbleweed

The dsPIC33CK/CH family is rated at 100MHz (100MIPS)

FWIW, the datasheet limit for the 24EP128GP202 is 70MHz.

normnet

Quote from: tumbleweed on Jul 21, 2021, 12:49 AMThe dsPIC33CK/CH family is rated at 100MHz (100MIPS)

FWIW, the datasheet limit for the 24EP128GP202 is 70MHz.

Les's example code sets the Declare Xtal = 140.03 for the 24EP128GP202

QuotePositron16 Additions
Added support for devices; dsPIC33CK32MP102, dsPIC33CK32MP103, dsPIC33CK32MP105, dsPIC33CK32MP202, dsPIC33CK32MP203, dsPIC33CK32MP205, dsPIC33CK32MP206, dsPIC33CK32MP502, dsPIC33CK32MP503, dsPIC33CK32MP505, dsPIC33CK32MP506, dsPIC33CK64MP102, dsPIC33CK64MP103, dsPIC33CK64MP105, dsPIC33CK64MP202, dsPIC33CK64MP203, dsPIC33CK64MP205, dsPIC33CK64MP206, dsPIC33CK64MP208, dsPIC33CK64MP502, dsPIC33CK64MP503, dsPIC33CK64MP505, dsPIC33CK64MP506, dsPIC33CK64MP508, dsPIC33CK128MP202, dsPIC33CK256MP208, dsPIC33CK256MP502, dsPIC33CK256MP503, dsPIC33CK256MP505, dsPIC33CK256MP506, dsPIC33CK256MP508.

These are the newer dsPIC devices and offer a large set of internal peripherals and can operate up to 100 MIPS (200Mhz).

Norm

basparky

Thanks for helping.

So,yes i also noticed 70MHz for the pic24EP128GP202.Which example does declare the Xtal as 140.03?

Do i need this setting also for my dsPic?

top204

The program below will set a dsPIC33CK device to operate at 190MHz using its internal oscillator.

It will go to 200MHz, but it is a bit unstable with the internal oscillator at that speed. However, an external crystal multiplied up allowed the 200MHz operation to be extremely stable, and I even increased its frequency from 200MHz onwards with stability using the SFRs to manipulate its PLL settings. :-)

'
'   /\\\\\\\\\
'  /\\\///////\\\
'  \/\\\     \/\\\                                                 /\\\          /\\\
'   \/\\\\\\\\\\\/        /\\\\\     /\\\\\\\\\\     /\\\\\\\\   /\\\\\\\\\\\  /\\\\\\\\\\\  /\\\\\\\\\
'    \/\\\//////\\\      /\\\///\\\  \/\\\//////    /\\\/////\\\ \////\\\////  \////\\\////  \////////\\\
'     \/\\\    \//\\\    /\\\  \//\\\ \/\\\\\\\\\\  /\\\\\\\\\\\     \/\\\         \/\\\        /\\\\\\\\\\
'      \/\\\     \//\\\  \//\\\  /\\\  \////////\\\ \//\\///////      \/\\\ /\\     \/\\\ /\\   /\\\/////\\\
'       \/\\\      \//\\\  \///\\\\\/    /\\\\\\\\\\  \//\\\\\\\\\\    \//\\\\\      \//\\\\\   \//\\\\\\\\/\\
'        \///        \///     \/////     \//////////    \//////////      \/////        \/////     \////////\//
'                                  Let's find out together what makes a PIC Tick!
'
' Setup a dsPIC33CK device to operate at 190MHz with its internal oscillator.
'
' Written by Les Johnson for the Positron16 BASIC compiler.
' https://sites.google.com/view/rosetta-tech/home
'
    Device = 33CK128MP202
    Declare Xtal = 190
'
' Setup USART1 for the HRSout command
'
    Declare Hserial1_Baud = 115200
    Declare HRSOut1_Pin = PORTB.0
'
' PPS Pin numbers
'
$define PPS_OutPin_RB0  cOut_Pin_RP32
$define PPS_OutPin_RB1  cOut_Pin_RP33
$define PPS_OutPin_RB2  cOut_Pin_RP34
$define PPS_OutPin_RB3  cOut_Pin_RP35
$define PPS_OutPin_RB4  cOut_Pin_RP36
$define PPS_OutPin_RB5  cOut_Pin_RP37
$define PPS_OutPin_RB6  cOut_Pin_RP38
$define PPS_OutPin_RB7  cOut_Pin_RP39
$define PPS_OutPin_RB8  cOut_Pin_RP40
$define PPS_OutPin_RB9  cOut_Pin_RP41
$define PPS_OutPin_RB10 cOut_Pin_RP42
$define PPS_OutPin_RB11 cOut_Pin_RP43
$define PPS_OutPin_RB12 cOut_Pin_RP44
$define PPS_OutPin_RB13 cOut_Pin_RP45
$define PPS_OutPin_RB14 cOut_Pin_RP46
$define PPS_OutPin_RB15 cOut_Pin_RP47

$define PPS_OutPin_A0 PPS_OutPin_RB0
$define PPS_OutPin_A1 PPS_OutPin_RB1
$define PPS_OutPin_A2 PPS_OutPin_RB2
$define PPS_OutPin_A3 PPS_OutPin_RB3

'----------------------------------------------------------------------------------
' The main program starts here
'
Main:
    Osc_190MHz()                                ' Set the device to run at 190MHz

    PPS_Unlock()                                ' \
    PPS_Output(PPS_OutPin_RB0, cOut_Fn_U1TX)    ' / Set the USART1 PPS pin
'
' Display text on a serial terminal
'
    Do
        HRSOutLn "Hello World"
        DelayMS 500
    Loop

'---------------------------------------------------------------------------------
' Setup the device to operate at 190MHz with its internal oscillator
' Input     : None
' Output    : None
' Notes     : Waits for the oscillator to become stable
'
Proc Osc_190MHz()
    CLKDIV = $3001          ' FRCDIV FRC/1, PLLPRE 1, DOZE 1:8
    PLLFBD = 90
    OSCTUN = $00
    PLLDIV = $21            ' POST1DIV 1:2, VCODIV FVCO/4, POST2DIV 1:1
    ACLKCON1 = $0101        ' FRCSEL FRC, APLLPRE 1:1
    APLLFBD1 = $C8
    APLLDIV1 = $42          ' APOST1DIV 1:4, APOST2DIV 1:2, AVCODIV FVCO/4

    Write_OSCCONH($01)
    Write_OSCCONL($01)

    While OSCCONbits_OSWEN <> 0 : Wend  ' Wait for the clock switch to occur
EndProc

'----------------------------------------------------------------------------------
' Set the fuses for internal oscillator
'
    Config FSEC     = BWRP_OFF, BSS_DISABLED, BSEN_OFF, GWRP_OFF, GSS_DISABLED, CWRP_OFF, CSS_DISABLED, AIVTDIS_OFF
    Config FOSCSEL  = FNOSC_FRC, IESO_OFF
    Config FOSC     = POSCMD_NONE, OSCIOFNC_ON, FCKSM_CSECMD, PLLKEN_ON, XTCFG_G0, XTBST_ENABLE
    Config FWDT     = SWDTPS_PS2147483648, RCLKSEL_LPRC
    Config FPOR     = BISTDIS_DISABLED
    Config FICD     = ICS_PGD1, JTAGEN_OFF, NOBTSWP_DISABLED
    Config FDMT     = DMTDIS_OFF
    Config FDEVOPT  = ALTI2C1_OFF, ALTI2C2_OFF, ALTI2C3_OFF, SMBEN_STANDARD, SPI2PIN_PPS
    Config FALTREG  = CTXT1_OFF, CTXT2_OFF, CTXT3_OFF, CTXT4_OFF
    Config FBOOT    = BTMODE_SINGLE

basparky

#6
So how do I interpret this then?
The data page from the dsPIC33CK256MP508 gives:
Max CPU Speed (MHz)
100
CPU Speed (MIPS/DMIPS)
100
https://www.microchip.com/wwwproducts/en/dsPIC33CK256MP508

And you config it as 200MHz at max in the program?

Does this mean i can setup my dsPic as 140MHz at max?

normnet

  Device = 24EP128GP202    '10uf VCAP REQUIRED PIN 19 & 20
  Declare Xtal = 140.03

  Clear
' USART1 declares
  Declare Hserial_Baud = 115200           ' UART1 baud rate
  Declare Hrsout1_Pin = PORTB.3           ' Select which pin is to be used for TX with USART1
'  Declare Hrsin1_Pin = PORTB.2            ' Select which pin is to be used for RX with USART1

  Symbol cLED = PORTB.7  'use transistor
  Output cLED
  Dim yCNT As Byte

  TRISA = %00000000
  TRISB = %0000000011100000

'  PLL_Setup(43, 2, 2, $0300)              ' Configure the Oscillator to operate the device at 79.23MHz

  ' Setup the Oscillator to operate the device at 140.03MHz
  ' Fosc = (7.37 * 76) / (2 * 2) = 140.03MHz
  PLL_Setup(76, 2, 2, $0300)

  PPS_Output(cOut_Pin_RP35, cOut_Fn_U1TX)  ' Configure PPS to make Pin RB3 U1TX
  DelayMS 3000
  HSerOut[13,"START 140 MHz",13]
  While                                   ' Create an infinite loop
     Toggle cLED
     HSerOut[Dec yCNT,13]
     DelayMS 1000                        ' Create a delay
     Inc yCNT
  Wend                                    ' Do it forever

'-------------------------------------------------------------------------------

' Configure for internal 7.37MHz oscillator with PLL
' OSC pins are general purpose I/O
  Config FICD = ICS_PGD1, JTAGEN_OFF
  Config FPOR = ALTI2C1_OFF, ALTI2C2_OFF, WDTWIN_WIN75
  Config FWDT = FWDTEN_OFF, PLLKEN_ON, WDTPOST_PS512, WDTPRE_PR128, WINDIS_OFF
  Config FOSC = FCKSM_CSECME, IOL1WAY_OFF, OSCIOFNC_ON, POSCMD_NONE
  Config FOSCSEL = FNOSC_FRCPLL, IESO_OFF
  Config FGS = GCP_OFF, GWRP_OFF

  End

tumbleweed

QuoteSo how do I interpret this then?
Interpret this as you like.
Exceeding the datasheet specs... it's all on you.

top204

#9
The Microchip datasheets are now notoriously bad to read and are, generally, full of copy and pastes from other device datasheets. Nothing, even nearly, as good as they once were.

I have also nothiced that some datasheets do not discern 'MIPS' from 'operating frequency' clearly enough. The PIC24 and dsPIC33 devices have an internal operating ratio of 2:1, so for every 2 cycles of the actual oscillator frequency, an instruction will be carried out. i.e. 'MIPS' Million Instructions Per Second.

The dsPIC33CK devices have a maximum 'operating' frequency of 200MHz, so their instruction cycle is 100 MIPS, usually mistaken in the datasheets as 100MHz. i.e. 200MHz / 2.

basparky

#10
Thanks for helping!

So my dsPic does 70MIPS following the datasheet which i have to believe and for this i need to configure the PIC as 140MHz, right?
Device = 33EP256GP502
Config FICD = ICS_PGD1, JTAGEN_ON
Config FPOR = ALTI2C1_OFF, ALTI2C2_OFF, WDTWIN_WIN25
Config FWDT = FWDTEN_ON, PLLKEN_ON, WDTPOST_PS32768, WDTPRE_PR128, WINDIS_OFF
Config Fosc = FCKSM_CSDCMD, IOL1WAY_ON, OSCIOFNC_OFF, POSCMD_HS
Config FOSCSEL = FNOSC_PRIPLL, IESO_ON
Config FGS = GCP_OFF, GWRP_OFF

Declare Xtal = 140
;-------------------------------------------------------------------------------
'Fosc = (10 * 56) / (2 * 2) = (140MHz)
PLL_Setup(56,2,2,$0300)

Correct?

BTW Nice devices those dsPic33CK. when will the 256 Flash versions supported?

tumbleweed

QuoteThe dsPIC33CK devices have a maximum 'operating' frequency of 200MHz, so their instruction cycle is 100 MIPS
My bad... I've been misinterpreting what you've been saying. Sorry about that!