Shop OBEX P1 Docs P2 Docs Learn Events
PropBASIC and C3 board — Parallax Forums

PropBASIC and C3 board

RsadeikaRsadeika Posts: 3,837
edited 2013-08-23 08:54 in Propeller 1
The first big question is - will Bean provide an XMM mode to address the flash and static RAM that is available on the board?

I was looking for my Demo Board but could not find it, but I noticed that my C3 board is collecting dust also, what to do? So I decided that I might try a small expanding experiment that would end up being a headless/stand-alone C3 board.

For the headless part I will have an XBee running as a TASK to provide a wireless connect. This should be relatively simple since I have started the XBee TASK code.

For the stand-alone part I will need some drivers for the keyboard, and VGA which the C3 board has. Access to the VGA, on the C3 is a little different, so I think somebody might have to explain to me how that is done. And then down the road maybe somebody will have developed some code for the SD card, which the C3 also has.

The next step will be is to find some PropBASIC code that will provide access to a keyboard. With a keyboard attached I will then try to get some characters onto the SimpleIDE terminal screen, which will be replaced by a VGA monitor a some point.

Some start up code shown below.

Ray

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' PC3base.pbas
'
' August 22, 2013
'
' Use of Parallax C3 board.
'
''''''''''''''''''''
' Define hardware requirements
''''''''''''''''''''
DEVICE          P8X32A, XTAL1, PLL16X
XIN             5_000_000

LED1 PIN 23 LOW

LOAD "pbasic.lib"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

''''''''''''''''''''
PROGRAM Start
''''''''''''''''''''

Start:
' Wait for terminal screen.
  wait_MS 300

Main:
  tx_STR "The PC3Base Program.\r\n"
  tx_STR "Sit and watch the LED flash.\r\n"

  DO
    HIGH LED1
    wait_MS 1000
    LOW LED1
    wait_MS 1000    
  LOOP

END

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Comments

  • BeanBean Posts: 8,129
    edited 2013-08-22 11:59
    I haven't looked at any XMM methods yet. But it would be cool.

    Here is a program to read a PS/2 keyboard and send the characters back to the terminal. Enjoy...

    Bean
    DEVICE P8X32A, XTAL1, PLL16X
    FREQ 80_000_000
    
    ' This is a demo program for PropBASIC
    ' Reads keys from the PS2 keyboard connected to the Prop Demo Board
    '  and sends the characters to the PC. Use the Parallax Serial Terminal
    '  program is view the received characters.
    
    ' Define constants
    Baud   CON "T115200"
    
    
    ' Define pins
    KeyDat    PIN 26 INPUT
    KeyClk    PIN 27 INPUT
    TX        PIN 30 HIGH
    
    
    ' Define HUB variables
    lastKey   HUB BYTE
    
    
    ' Define DATA (DATA, WDATA, LDATA)
    ' Unshifted characters
    KeyCodes1 DATA  0,   0,   0,   0,   0,   0,   0,  0, 0,  0,   0,   0,   0,   9,  "`", 0 ' 00 to 0F
              DATA  0,   0,   0,   0,   0,  "q", "1", 0, 0,  0,  "z", "s", "a", "w", "2", 0 ' 10 to 1F
              DATA  0,  "c", "x", "d", "e", "4", "3", 0, 0, " ", "v", "f", "t", "r", "5", 0 ' 20 to 2F
              DATA  0,  "n", "b", "h", "g", "y", "6", 0, 0,  0,  "m", "j", "u", "7", "8", 0 ' 30 to 3F
              DATA  0,  ",", "k", "i", "o", "0", "9", 0, 0, ".", "/", "l", ";", "p", "-", 0 ' 40 to 4F
              DATA  0,   0,  39,  0,  "[", "=",  0,  0, 0,  0,  13,  "]",  0,  92,  0,  0 ' 50 to 5F
              DATA  0,   0,   0,   0,   0,   0,   8,  0, 0, "1",  0,  "4", "7",  0,   0,  0 ' 60 to 6F
              DATA "0", ".", "2", "5", "6", "8", 27,  0, 0, "+", "3", "-", "*", "9",  0,  0 ' 70 to 7F
    
    ' Shifted characters
    KeyCodes2 DATA  0,   0,   0,   0,   0,   0,   0,  0, 0,  0,   0,   0,   0,   9,  "~", 0 ' 00 to 0F
              DATA  0,   0,   0,   0,   0,  "Q", "!", 0, 0,  0,  "Z", "S", "A", "W", "@", 0 ' 10 to 1F
              DATA  0,  "C", "X", "D", "E", "$", "#", 0, 0, " ", "V", "F", "T", "R", "%", 0 ' 20 to 2F
              DATA  0,  "N", "B", "H", "G", "Y", "^", 0, 0,  0,  "M", "J", "U", "&", "*", 0 ' 30 to 3F
              DATA  0,  "<", "K", "I", "O", "0", "(", 0, 0, ">", "?", "L", ":", "P", "_", 0 ' 40 to 4F
              DATA  0,   0,  34,   0,  "{", "=",  0,  0, 0,  0,  13,  "}",  0,  "|",  0,  0 ' 50 to 5F
              DATA  0,   0,   0,   0,   0,   0,   8,  0, 0, "1",  0,  "4", "7",  0,   0,  0 ' 60 to 6F
              DATA "0", ".", "2", "5", "6", "8", 27,  0, 0, "+", "3", "-", "*", "9",  0,  0 ' 70 to 7F
    
    
    ' Define TASKs
    ReadKey  TASK
    
    
    ' Define variables (LONGs only)
    temp     VAR LONG
    
    
    ' Define Subroutines
    ' none
    
    ' Main program
    PROGRAM Start
    
    Start:
      COGSTART ReadKey
      DO
        RDBYTE lastKey, temp
        IF temp > 0 THEN
          WRBYTE lastKey, 0
          SEROUT TX, Baud, temp
        ENDIF
      LOOP
    END
    
    ' Subroutine Code
    ' none
    
    
    ' Task Code
    TASK ReadKey
    
    bits     VAR LONG
    value    VAR LONG
    tempAddr VAR LONG
    shift    VAR LONG
    skipNext VAR LONG
    
    GetCode  FUNC 0
    
      shift = 0 ' Shift not down
      DO
        value = GetCode
        ' $12 and $59 are the shift keys
        IF value = $12 OR
         value = $59 THEN
          shift = ~shift
        ELSEIF value = $F0 THEN 
          ' $F0 = Release code, just ignore next keycode
          GetCode
        ELSEIF value < 128 THEN
          ' Get character from table (depending on shift status)
          IF shift THEN
            tempAddr = GetAddr KeyCodes2
          ELSE
            tempAddr = GetAddr KeyCodes1
          ENDIF
          tempAddr = tempAddr + value
          RDBYTE tempAddr, value
          IF value > 0 THEN
            WRBYTE lastKey, value
          ENDIF
        ENDIF
      LOOP
    
    FUNC GetCode
      ' Wait for a zero bit
      DO
        WAITPEQ KeyClk, KeyClk
        WAITPNE KeyClk, KeyClk
      LOOP UNTIL KeyDat = 0
    
      ' Receive 10 bits, 8 data, 1 parity, 1 stop
      value = 0
      FOR bits = 0 TO 9
        WAITPEQ KeyClk, KeyClk
        WAITPNE KeyClk, KeyClk
        value = value >> 1
        IF keyDat = 1 THEN
          value = value OR 512
        ENDIF
      NEXT
      ' Mask off parity and stop bit
      value = value AND 255
      RETURN value
    ENDFUNC
    
    ENDTASK
    
    
    
  • jazzedjazzed Posts: 11,803
    edited 2013-08-22 12:58
    Bean,

    There are several "xmm" approaches if you want to talk about them.

    David Betz wrote xbasic several years ago that uses a byte-code interpreter and xmm code.
    I wrote my first hand-held LCD project with that. The resulting code is very small.

    I wrote a GUI for xbasic too: http://www.microcsource.com/software.htm ... it should look familiar.
  • kuronekokuroneko Posts: 3,623
    edited 2013-08-22 17:53
    Rsadeika wrote: »
    Access to the VGA, on the C3 is a little different, so I think somebody might have to explain to me how that is done.
    http://forums.parallax.com/showthread.php/131078-C3-MikronautsVGA80-keyboard-test-program
  • jazzedjazzed Posts: 11,803
    edited 2013-08-22 18:17
    Bill, Marko, Ray or anyone???

    I saw mention of a single COG MicronautsVGA80.spin in that thread that only needs a 5MHz crystal.
    Saw the over-clocked version posted, but that's not widely used because most boards use 5MHz.

    Several of us would certainly appreciate having such a VGA driver for various projects.
    Any clues to where they are? Nothing in the OBEX that I can find.

    Thanks,
    --Steve
  • kuronekokuroneko Posts: 3,623
    edited 2013-08-22 18:51
    jazzed wrote: »
    I saw mention of a single COG MicronautsVGA80.spin in that thread that only needs a 5MHz crystal.
    I don't recall that there ever was a single cog 5MHz version for the 80 column driver. All I can offer right now is a [thread=146085]100 column monochrome driver[/thread] (with screen/font relocation removed, i.e. at startup only, there may be space for per line colour).
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-08-23 03:58
    I worked in the external keyboard code, Thanks Bean, now you can attach a keyboard, and type away. I also included a zip file that contains the whole project code. I added a get_KEY subroutine, but I think I will need a get_KEYS sub also, to capture a string of characters and have it compared to defined commands. Not sure how I will be doing that, suggestions are welcome. At some point a VGA driver will become available, then the get_KEY/get_KEYS will be used to drive the VGA.

    A couple of things I noticed with the state of SimpleIDE, can it still run Spin projects, or do you have to have a separate SimpleIDE for doing PropGCC/Spin projects? I ask because I noticed PropBasic provides some Spin programs of the PC3base project, but when I tried to run that code, it does not compile. I was going to add a 'Program Start LMM' to the PC3base code just to see what the resulting Spin program would look like, and if it really used LMM in a Spin program.

    What I am looking for, in this experiment, is a 'DOS' look and feel, of the old days. I remember the amber or green CRT display, with the characters being displayed were very crisp and readable in the 80x24 format. With most of the monitors today being widescreen it might be a challenge to come up with comparable result, not looking for an amber/green affect, but some color for characters or strings, would be nice.

    Now I still need to work out the string capture compare to a command problem.

    Ray
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' PC3base.pbas
    '
    ' August 22, 2013
    '
    ' Use of Parallax C3 board.
    '
    ''''''''''''''''''''
    ' Define hardware requirements
    ''''''''''''''''''''
    DEVICE P8X32A, XTAL1, PLL16X
    XIN    5_000_000
    
    
    
    ' Define PS/2 pins for external keyboard use.
    KeyDat    PIN 26 INPUT
    KeyClk    PIN 27 INPUT
    
    
    
    ' Define HUB variables
    lastKey   HUB BYTE
    
    ' Load the keyboard DATA values.
    LOAD "kbrdData.pbas"
    ' Load common subroutines/functions.
    LOAD "pbasic.lib"
    
    
    get_KEY SUB 1
    
    ' Define TASKs
    ReadKey  TASK
    
    
    ' Define variables (LONGs only)
    temp  VAR LONG
    cog1  VAR LONG
    
    ''''''''''''''''''''
    PROGRAM Start
    ''''''''''''''''''''
    
    Start:
    ' Wait for terminal screen.
      wait_MS 300
    
      COGSTART ReadKey,cog1  ' Label the cog.
    
    Main:
      tx_STR "The PC3Base Program\r\n"
      tx_STR "Start using the external keyboard\r\n"
      
      DO 
        get_KEY temp         ' Read a keypress
        IF temp = "q" THEN
          EXIT
        ENDIF
      LOOP
    
      tx_STR "Program Halted!\r\n"
      COGSTOP cog1  ' Stop the ReadKey TASK
    
    END
    
    ' Subroutine Code
    '
    SUB get_KEY
    '        HUB Byte LONG
      RDBYTE lastKey, temp
        IF temp > 0 THEN
          WRBYTE lastKey, 0
          tx_BYTE temp       ' Display the keypress
        ENDIF
    ENDSUB
    
    LOAD "kbrdTask.pbas"
    
    
  • Bill HenningBill Henning Posts: 6,445
    edited 2013-08-23 07:43
    Hi Steve,

    People were asking for it, but a good 80 column 80Mhz single cog driver (on a P1) was not practical as one to two scan lines would have had to be blank between each row of text, which was not sufficient for me (as I wanted graphics characters and an inverse functionality).

    At 100Mhz there is exactly enough time to do it, as I made interleaved fonts allowing the inner loop to execute in 32 cycles per 8 pixels (25Mhz dot clock) synchronized to the hub (kuroneko was kind enough to help me sync to the hub)

    On a P2 however it is VERY easy, heck it should only take one hardware thread!

    jazzed wrote: »
    Bill, Marko, Ray or anyone???

    I saw mention of a single COG MicronautsVGA80.spin in that thread that only needs a 5MHz crystal.
    Saw the over-clocked version posted, but that's not widely used because most boards use 5MHz.

    Several of us would certainly appreciate having such a VGA driver for various projects.
    Any clues to where they are? Nothing in the OBEX that I can find.

    Thanks,
    --Steve
  • Bill HenningBill Henning Posts: 6,445
    edited 2013-08-23 08:01
    I forgot to mention:

    I could make a 64 column one cog driver, but there would be some visual artifacts on vertical line segments.
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-08-23 08:54
    Does anybody know or remember what the character pixalation(is this the correct term) was for those old CRT monitors were? The Propeller VGA drivers that I had looked at, it seemed like the characters were not appealing to the eye at all. But, because I was viewing it on a wide screen monitor, that may have had something to do with it.

    For my experiment, if it took two cogs to achieve 80x24, and I could use one of the cogs too handle the keyboard, that would be a reasonable approach. Again, a reminder that this would be done in PropBASIC, and probably one of the PropBASIC experts would have to make the code usable.

    Ray
Sign In or Register to comment.