Shop OBEX P1 Docs P2 Docs Learn Events
PropBasic- \CLKSET and BAUD — Parallax Forums

PropBasic- \CLKSET and BAUD

camelot2camelot2 Posts: 54
edited 2010-09-28 04:46 in Propeller 1
What I want to do is run a program at a system freq of 100MHz, send some
data to the serial terminal then change the system freq to 50MHZ and send
some more data to the serial terminal then end. When I run the following
program the serial terminal displays
Dave1_
`0?<x?f<??
and not
Dave1
Dave2
It seems that when the system freq is changed the BAUD is not adjusted
correctly. How do you change the system freq and have a correct BAUD???
Here is the program - thanks for your help - Dave

' Device Settings
'
DEVICE P8X32A, XTAL1, PLL16X
XIN 6_250_000
'
Baud CON "T9600"
CR CON 13
'
' I/O Pins
'
RX PIN 31 INPUT
TX PIN 30 HIGH ' set to idle (true)
'
' Cog Variables (Long only)
'
NewFreq VAR LONG
'
' SUB/FUNC Definitions
'
' ======================================================================
PROGRAM Start
' ======================================================================
Start:
SEROUT 30, Baud, "Dave1"
SEROUT 30, Baud, CR
NewFreq = %01101110 'set the clk to PLL8X
\CLKSET NewFreq 'system clk should now be 50MHz ???
PAUSE 1000 'pause 1000ms
SEROUT 30, BAUD , "Dave2"
END

Comments

  • kwinnkwinn Posts: 8,697
    edited 2010-09-24 06:37
    Not surprising the baud rate is not adjusted when the clock frequency changes. The serial data objects calculate a timing constant at startup using the initial clock frequency and desired baud rate. You need to calculate the correct timing constant for the new clock frequency.
  • camelot2camelot2 Posts: 54
    edited 2010-09-24 07:29
    thanks kwinn , how do I do this calculation - thanks again - Dave
  • camelot2camelot2 Posts: 54
    edited 2010-09-27 08:37
    hi again, could someone please show me how to do the calculation mentioned by kwinn
    thanks for your help - Dave
  • BeanBean Posts: 8,129
    edited 2010-09-28 04:46
    The baud calculation is a constant. You cannot change it.
    Just use twice the baud rate when you change to 50MHz.

    ' Device Settings
    ' ----------------------------------------------------------------------
    DEVICE P8X32A, XTAL1, PLL16X
    XIN 6_250_000
    ' ----------------------------------------------------------------------
    Baud100 CON "T9600"
    Baud50  CON "T19200"
    CR CON 13
    ' ----------------------------------------------------------------------
    ' I/O Pins
    ' ----------------------------------------------------------------------
    RX PIN 31 INPUT
    TX PIN 30 HIGH ' set to idle (true)
    ' ----------------------------------------------------------------------
    ' Cog Variables (Long only)
    ' ----------------------------------------------------------------------
    NewFreq VAR LONG
    ' ----------------------------------------------------------------------
    ' SUB/FUNC Definitions
    ' ----------------------------------------------------------------------
    ' ================================================== ====================
    PROGRAM Start
    ' ================================================== ====================
    Start:
    SEROUT 30, Baud100, "Dave1"
    SEROUT 30, Baud100, CR
    NewFreq = %01101110 'set the clk to PLL8X
    \CLKSET NewFreq 'system clk should now be 50MHz ???
    PAUSE 500 'pause 1000ms
    SEROUT 30, BAUD50 , "Dave2"
    END 
    

    Bean
Sign In or Register to comment.