Rabbit Semiconductor makes a wide array of single board computers that use their Dynamic C language. These boards are very powerful, have a wide range of options, and are relatively inexpensive. With SeaBass it is possible to program these powerful computers using a familiar Basic-like language.

Dynamic C is not quite 100% C compatible. Also, you'll most often use the Dynamic C IDE as the device programmer for the Rabbit. This isn't much a problem, though. You simply need to tell SeaBass not to generate #line directives (the -l option) and to not try to build the resulting program (the -c option). If you use the GUI, your options would look like this:

Consider this simple SeaBass program for the JackRabbit board:

` Example Rabbit program using SeaBass
` delay a bit
sub delay(n as int)
Dim j
for j=0 to n
next
end sub
` make PortA an output port
sub PortAOutput()
WrPortI(SPCR, &SPCRShadow, 0x84)
end sub
` Set or clear a bit on PORTA
sub OutputA(bit as int, state as int)
BitWrPortI(PADR,&PADRShadow, state, bit)
end sub
sub main()
PortAOutput()
do while 1      ` do forever
  OutputA(2,1)  ` flip some bits
  OutputA(1,1)
  delay(25000)
  OutputA(2,0)
  OutputA(1,0)
  delay(30000)
loop
end sub

Notice that like all SeaBass programs, this one can transparently call C functions (like the built in WrPortI and BitWrPortI functions). When you compile the code, you wind up with C source that you can load into the Dynamic C IDE.

Pressing F9 will run your program. You can also single step your C code, examine variables, and so on in the usual way.

Here's a more complex piece of code that sends some Morse code:

` Example SeaBass Program
` Sends a little Morse code on an LED
` Define a string type
deftype string char *
` Speed of a dot (in counts)
Const speed=25000
` delay a bit
sub delay(n as int)
Dim j
for j=0 to n
next
end sub
` delay 3x as long
sub delay3(n as int)
Dim j
for j=1 to 3
  delay(n)
next
end sub
` make PortA an output port
sub PortAOutput()
WrPortI(SPCR, &SPCRShadow, 0x84)
WrPortI(PADR, &PADRShadow, 0xFF)  ` all LEDs off
end sub
` Set or clear a bit on PORTA
sub OutputA(bit as int, state as int)
BitWrPortI(PADR,&PADRShadow, state, bit)
end sub

` play a dot
sub dot()
  OutputA(0,0)
  delay(speed)
  OutputA(0,1)
  delay(speed)
end sub
` play a dash
sub dash()
  OutputA(0,0)
  delay3(speed)
  OutputA(0,1)
  delay(speed)
end sub
` pause between characters
sub space()
  delay3(speed)
end sub
` Main program
function main() as int
  dim text as string
  dim i
  text="-.-. --.-"   ` message to send
` Set LED to output
  PortAOutput()
` Main code
top:
  for i=0 to strlen(text)-1   ` walk through text
` do the right thing
     if text[i]='.' then
       dot()
     end if
     if text[i]='-' then
       dash()
     end if
     if text[i]=' ' then
       space()
     end if
  next
  for i= 1 to 100
     delay3(1000)   ` wait a long time
  next
  goto top          ` and do it again
end function

This is almost exactly the same as the AVR version of the code except for the parts that handle the delay and the actual LED manipulations. Of course, you could hide all of the I/O calls in a SeaBass library (and pull it in with an include statement) if you wanted to hide all of the Rabbit-specific registers and C calls.

You can experiment with SeaBass online if you like at http://www.awce.com/sbdemo.htm.


Site contents © 1997-2018 by AWC, Houston TX    (281) 334-4341