Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length



Pages: [1]
  Print  
Author Topic: UART baud rate below 9600  (Read 807 times)
whiz100
Newbie
*
Posts: 4


View Profile
« on: September 22, 2009, 01:50:10 PM »

is it possible to set the baud rate to something less than 9600?
Logged
SupportAdmin
Administrator
Hero Member
*****
Posts: 5394



View Profile WWW
« Reply #1 on: September 22, 2009, 02:51:35 PM »

I believe ti is possible but why lower?
Logged
whiz100
Newbie
*
Posts: 4


View Profile
« Reply #2 on: September 22, 2009, 04:53:28 PM »

I'm using a BS2 which is having difficulty with 9600, it's missing bytes when reading data. the BS2 will probably have problems at 4800 also according to the manual.

Logged
SupportAdmin
Administrator
Hero Member
*****
Posts: 5394



View Profile WWW
« Reply #3 on: September 22, 2009, 06:44:18 PM »

BS2+uALFAT then why not use USBizi? Take a look at the free ebook on the USBizi board
Logged
whiz100
Newbie
*
Posts: 4


View Profile
« Reply #4 on: September 22, 2009, 07:20:26 PM »

looks very nice, bit overkill for what I need.

couldn't see any reference to setting the baud rate below 9600 for the uALFAT.

so do you know what values I need to set the baud rate below 9600?

thanks
P
Logged
srodriguez14
Newbie
*
Posts: 5


View Profile
« Reply #5 on: February 25, 2010, 08:32:00 PM »

Whiz did you ever find out how to use a lower baudrate.
Logged
whiz100
Newbie
*
Posts: 4


View Profile
« Reply #6 on: February 25, 2010, 10:57:00 PM »

no i didn't - just could get the BS to work using uart. but I did get it working just fine with some bit banging the SPI.

------------- code below here is for bit banging SPI ---------
Code:
' {$STAMP BS2}
' {$PBASIC 2.5}


' setup o/i pins
dataready PIN 15
busy PIN 14
spi_sck PIN 13
spi_miso PIN 12
spi_mosi PIN 11
spi_ssel PIN 10
reset PIN 9

' INSTRUCTIONS
'>O 1R>boot<CR>
'<!00<CR>
' loop
'>R 1^>1<CR>
'<!00<CR>
'<X$00000001<CR>          ------ result is 1 when something was read, note this is the left that was actuall read ---
'<!00<CR>
' end loop when result is ---- start end of file -----
'>R 1^>1<CR>
'<!00<CR>
'<^$00000000<CR>               ----- result is 0 when nothing left to read -----
'<!00<CR>
'end of file result       ----- finish end of file result -----
'>C 1<CR>
'<!00<CR>
'>Z H<CR>
'<!00<CR>


''''''''''' begin main loop ''''''''''''

cmd VAR Byte(10)
counter VAR Byte

GOSUB func_Reset
DO WHILE dataready=1
    GOSUB func_ReadByte
    DEBUG STR inbyte\1
LOOP

DO
  DEBUG "cmd: "
  DEBUGIN  STR cmd  \10 \13
  'DEBUG STR ? cmd
  FOR counter = 0 TO 9
    IF cmd(counter)<>0 THEN
      outbyte=cmd(counter)
      GOSUB func_WriteByte
    ENDIF
  NEXT

  outbyte=13
  GOSUB func_WriteByte
'PAUSE 500
 DO
 DEBUG "."
   LOOP WHILE (dataready=0)
  DO WHILE dataready=1
    GOSUB func_ReadByte
    IF inbyte<>255 THEN
    DEBUG STR inbyte\1
    ENDIF
  LOOP

LOOP WHILE cmd<>"."
DEBUG "Finished",CR
STOP

'''''''''''''' uALFAT subroutines ''''''''''




func_Reset:
' reset to spi interface
HIGH reset                           ' reset pin
HIGH spi_ssel                           '  spi_ssel# (active low ) set high to activate SPI
HIGH spi_sck                           ' spi_sck set high to active SPI
PAUSE 5
LOW reset                            ' toggle reset
PAUSE 5
HIGH reset                           ' bring reset back
PAUSE 5
RETURN


' results from ReadByte function will be stored in this variable
inbyte VAR Byte
outbyte VAR Byte


func_ReadByte:
LOW spi_ssel   ' activate chip select (active low)
'PAUSE 100
DO:  LOOP WHILE (dataready=0)
HIGH spi_mosi    ' force 0xFF to uALFAT
HIGH spi_sck        ' idle high
bits VAR Byte
FOR bits = 0 TO 7
  LOW spi_sck                          ' ok to read data after this line
 'PAUSE 2
 ' read in the response
  inbyte = inbyte<<1
  inbyte = inbyte | spi_miso
  HIGH spi_sck
NEXT
RETURN



func_WriteByte:

LOW spi_ssel
' check the busy line
DO : LOOP WHILE (busy=1)
FOR bits = 0 TO 7

  IF outbyte.BIT7=0 THEN
  LOW spi_mosi
  ELSE
  HIGH spi_mosi
  ENDIF
  outbyte =outbyte<< 1
  LOW spi_sck
  PAUSE 2
  HIGH spi_sck
NEXT
RETURN
Logged
Pages: [1]
  Print  
 
Jump to: