Maker Pro
Maker Pro

Need Some Help Figuring Out How to Use the PDSP2112

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
That's looking pretty good to me. I would recommend you remove the display and insert LEDs on the outputs until you have the code to write to the 595's debugged.
 

KrisBlueNZ

Sadly passed away in 2015
Good idea Steve. Also, I don't think there's any need to drive the -RST inputs of the 595s, and again I suggest that you drive the display's -FL input from the micro until you know you won't need it.
 
Yes I will do that Steve, that is a very good idea! :)
I don't think there's any need to drive the -RST inputs of the 595s, and again I suggest that you drive the display's -FL input from the micro until you know you won't need it.
OK, no probs Kris. I fix that when I post the code. :)

FYI: I going to try and get one of my other projects done before I work on the code for this one, so I can free up the breadboard for this project... So it might be a while before I post any code.

Just thought I would let you guys know, so won't think I ditched this project. :D

Thanks for all the help Kris and Steve!! :)
Dan
 
Took a little longer then I thought. o_O Here's the code:
Code:
;*********************************************************;
;*             <- START OF PDSP PROGRAM ->               *;
;*********************************************************;
;*********************************************************;
;* This program displays 'Hello!' on the PDSP2112        *;
;*********************************************************;

;***********************PIN_LAYOUT************************;
;*   PIN___FUNCTION || PIN___FUNCTION || PIN___FUNCTION  *;
;*   C.4    -CE     || C.2    -FL     || C.1    -WR      *;
;*   C.0    -RST    || B.2   SHFCLK 11|| B.3   LCHCLK 12 *;
;*   B.4   SDI      ||                ||                 *;
;*********************************************************;
;*********************************************************;
;* This section is for renaming variables and constants  *;
;*********************************************************;
symbol nCE=c.4
symbol nRST=c.0
symbol SDI=b.4
symbol nFL=c.2
symbol SHFCLK=b.2
symbol nWR=c.1
symbol LCHCLK=b.3
symbol TM=2 ;this will make all delays 5.7uS

;*********************************************************;
;* This is the main code which was made so it would      *;
;* be easy to change what's on the display               *;
;*********************************************************;

main: ;make all variables equal to zero only done once
    let bit1=0
    let bit2=0
    let bit3=0
    let bit4=0
    let bit5=0
    let bit6=0
    let bit7=0
    let bit8=0
    let bit9=0
    let bit10=0
    let bit11=0
    let bit12=0
    let b10=0
    goto start
start:
    low SHFCLK,LCHCLK,SDI
    high nCE,nWR,nRST,nFL ;a do nothing state
    pauseus TM ;let it register
    low nRST ;start the clear process
    pauseus TM ;let it register
    high nRST ;disable the rest pin
    pauseus TM ;let it register
    low nCE ;get access to the display
    do ;start endless loop
        let bit1=0 ; 'H' 100000011000
        let bit2=0
        let bit3=0
        let bit4=1
        let bit5=1
        let bit6=0
        let bit7=0
        let bit8=0
        let bit9=0
        let bit10=0
        let bit11=0
        let bit12=1
        gosub display
        let bit1=0 ;'e' 010010101100
        let bit2=0
        let bit3=1
        let bit4=1
        let bit5=0
        let bit6=1
        let bit7=0
        let bit8=1
        let bit9=0
        let bit10=0
        let bit11=1
        let bit12=0
        gosub display
        let bit1=0 ;'l' 110000111100
        let bit2=0
        let bit3=1
        let bit4=1
        let bit5=1
        let bit6=1
        let bit7=0
        let bit8=0
        let bit9=0
        let bit10=0
        let bit11=1
        let bit12=1
        gosub display
        let bit1=0 ;'l' 001000111100
        let bit2=0
        let bit3=1
        let bit4=1
        let bit5=1
        let bit6=1
        let bit7=0
        let bit8=0
        let bit9=0
        let bit10=1
        let bit11=0
        let bit12=0
        gosub display
        let bit1=0 ;'o' 101011111100
        let bit2=0
        let bit3=1
        let bit4=1
        let bit5=1
        let bit6=1
        let bit7=1
        let bit8=1
        let bit9=0
        let bit10=1
        let bit11=0
        let bit12=1
        gosub display
        let bit1=0 ;'!' 011010000100
        let bit2=0
        let bit3=1
        let bit4=0
        let bit5=0
        let bit6=0
        let bit7=0
        let bit8=1
        let bit9=0
        let bit10=1
        let bit11=1
        let bit12=0
        gosub display
    loop until b10=0 ;endless loop

    ;***************************************************;
    ;* this stores the data above in the shift         *;
    ;* register/display.                               *;
    ;***************************************************;
    display:
        if bit1=1 then ;decide to load a 1 or 0 to the shift register
            high SDI
            else
                low SDI
        endif
        pauseus TM ;let it register
        high SHFCLK ;load value to shift register
        pauseus TM ;let it register
        low SHFCLK
        if bit2=1 then ;decide to load a 1 or 0 to the shift register
            high SDI
            else
                low SDI
        endif
        pauseus TM ;let it register
        high SHFCLK ;load value to shift register
        pauseus TM ;let it register
        low SHFCLK
        if bit3=1 then ;decide to load a 1 or 0 to the shift register
            high SDI
            else
                low SDI
        endif
        pauseus TM ;let it register
        high SHFCLK ;load value to shift register
        pauseus TM ;let it register
        low SHFCLK
        if bit4=1 then ;decide to load a 1 or 0 to the shift register
            high SDI
            else
                low SDI
        endif
        pauseus TM ;let it register
        high SHFCLK ;load value to shift register
        pauseus TM ;let it register
        low SHFCLK
        if bit5=1 then ;decide to load a 1 or 0 to the shift register
            high SDI
            else
                low SDI
        endif
        pauseus TM ;let it register
        high SHFCLK ;load value to shift register
        pauseus TM ;let it register
        low SHFCLK
        if bit6=1 then ;decide to load a 1 or 0 to the shift register
            high SDI
            else
                low SDI
        endif
        pauseus TM ;let it register
        high SHFCLK ;load value to shift register
        pauseus TM ;let it register
        low SHFCLK
        if bit7=1 then ;decide to load a 1 or 0 to the shift register
            high SDI
            else
                low SDI
        endif
        pauseus TM ;let it register
        high SHFCLK ;load value to shift register
        pauseus TM ;let it register
        low SHFCLK
        if bit8=1 then ;decide to load a 1 or 0 to the shift register
            high SDI
            else
                low SDI
        endif
        pauseus TM ;let it register
        high SHFCLK ;load value to shift register
        pauseus TM ;let it register
        low SHFCLK
        if bit9=1 then ;decide to load a 1 or 0 to the shift register
            high SDI
            else
                low SDI
        endif
        pauseus TM ;let it register
        high SHFCLK ;load value to shift register
        pauseus TM ;let it register
        low SHFCLK
        if bit10=1 then ;decide to load a 1 or 0 to the shift register
            high SDI
            else
                low SDI
        endif
        pauseus TM ;let it register
        high SHFCLK ;load value to shift register
        pauseus TM ;let it register
        low SHFCLK
        if bit11=1 then ;decide to load a 1 or 0 to the shift register
            high SDI
            else
                low SDI
        endif
        pauseus TM ;let it register
        high SHFCLK ;load value to shift register
        pauseus TM ;let it register
        low SHFCLK
        if bit12=1 then ;decide to load a 1 or 0 to the shift register
            high SDI
            else
                low SDI
        endif
        pauseus TM ;let it register
        high SHFCLK ;load value to shift register
        pauseus TM ;let it register
        low SHFCLK
        pauseus TM ;let it register
        high LCHCLK ;load shift register to the output
        pauseus TM ;let it register
        low LCHCLK
        pauseus TM ;let it register
        low nWR ;put it on the PDSP2112
        pauseus TM ;let it register
        high nWR ;remove access from the display
        pauseus TM ;let it register

;*********************************************************;
;*              <- END OF PDSP PROGRAM ->                *;
;*********************************************************;
;*********************************************************;
;* Version 1.0 Supercap2F                                *;
;*-------------------------------------------------------*;
;* Update list:                                          *;
;* 1) - Code Complete - Supercap2F - 10/28/2014          *;
;*                                                       *;
;*                                                       *;
;*                                                       *;
;*                                                       *;
;*********************************************************;
And here's the schematic (sorry about it being kind of awkward looking):
PDSPIM_10_28_2014_#1.jpg

I look forward to hearing your comments! :)
Dan
 

Attachments

  • PDSP_CODE_10_28_2014_#1.txt
    7 KB · Views: 147
Last edited:

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
It would be far better to use a structure which wouldn't require you replicate the code so many times.

Two options are an array and an integer (or similar) large enough to hold the entire bit pattern.
 
It would be far better to use a structure which wouldn't require you replicate the code so many times.
Hey! I just learned about them a day or two ago in C! :) But I don't know if they will work with a PICAXE. I had a look over the commands and I didn't see anything that would work like they do.
Two options are an array and an integer (or similar) large enough to hold the entire bit pattern.
Ahh, a solution! I don't think you can do arrays with a PICAXE either. But! a integer will work! :) b0 and b1 are made of bit0-bit15 and w0 is made of b0 and b1. So I can set w0 to say, 2072 and it will make bit0-bit11 equal 100000011000, and set the display to 'H'. Is this what you had in mind? Assuming that it is, here's the code updated to have it:
Code:
;*********************************************************;
;*             <- START OF PDSP PROGRAM ->               *;
;*********************************************************;
;*********************************************************;
;* This program displays 'Hello!' on the PDSP2112        *;
;*********************************************************;

;***********************PIN_LAYOUT************************;
;*   PIN___FUNCTION || PIN___FUNCTION || PIN___FUNCTION  *;
;*   C.4    -CE     || C.2    -FL     || C.1    -WR      *;
;*   C.0    -RST    || B.2   SHFCLK 11|| B.3   LCHCLK 12 *;
;*   B.4   SDI      ||                ||                 *;
;*********************************************************;
;*********************************************************;
;* This section is for renaming variables and constants  *;
;*********************************************************;
symbol nCE=c.4
symbol nRST=c.0
symbol SDI=b.4
symbol nFL=c.2
symbol SHFCLK=b.2
symbol nWR=c.1
symbol LCHCLK=b.3
symbol TM=2 ;this will make all delays 5.7uS

;*********************************************************;
;* This is the main code which was made so it would      *;
;* be easy to change what's on the display               *;
;*********************************************************;

main: ;make all variables equal to zero only done once
    let bit1=0
    let bit2=0
    let bit3=0
    let bit4=0
    let bit5=0
    let bit6=0
    let bit7=0
    let bit8=0
    let bit9=0
    let bit10=0
    let bit11=0
    let bit12=0
    let b10=0
    goto start
start:
    low SHFCLK,LCHCLK,SDI
    high nCE,nWR,nRST,nFL ;a do nothing state
    pauseus TM ;let it register
    low nRST ;start the clear process
    pauseus TM ;let it register
    high nRST ;disable the rest pin
    pauseus TM ;let it register
    low nCE ;get access to the display
    do ;start endless loop
        let w0=2072 ;let w0=2072=100000011000='H'
        gosub display
        let w0=1196 ;let w0=1196=010010101100='e'
        gosub display
        let w0=3132 ;let w0=3132=110000111100='l'
        gosub display
        let w0=572 ;let w0=572=001000111100='l'
        gosub display
        let w0=2812 ;let w0=2812=101011111100='o'
        gosub display
        let w0=1668 ;let w0=1668=011010000100='!'
        gosub display
    loop until b10=0 ;endless loop
    
    ;***************************************************;
    ;* this stores the data above in the shift         *;
    ;* register/display.                               *;
    ;***************************************************;
    display:
        if bit0=1 then ;decide to load a 1 or 0 to the shift register
            high SDI
            else
                low SDI
        endif
        pauseus TM ;let it register
        high SHFCLK ;load value to shift register
        pauseus TM ;let it register
        low SHFCLK
        if bit1=1 then ;decide to load a 1 or 0 to the shift register
            high SDI
            else
                low SDI
        endif
        pauseus TM ;let it register
        high SHFCLK ;load value to shift register
        pauseus TM ;let it register
        low SHFCLK
        if bit2=1 then ;decide to load a 1 or 0 to the shift register
            high SDI
            else
                low SDI
        endif
        pauseus TM ;let it register
        high SHFCLK ;load value to shift register
        pauseus TM ;let it register
        low SHFCLK
        if bit3=1 then ;decide to load a 1 or 0 to the shift register
            high SDI
            else
                low SDI
        endif
        pauseus TM ;let it register
        high SHFCLK ;load value to shift register
        pauseus TM ;let it register
        low SHFCLK
        if bit4=1 then ;decide to load a 1 or 0 to the shift register
            high SDI
            else
                low SDI
        endif
        pauseus TM ;let it register
        high SHFCLK ;load value to shift register
        pauseus TM ;let it register
        low SHFCLK
        if bit5=1 then ;decide to load a 1 or 0 to the shift register
            high SDI
            else
                low SDI
        endif
        pauseus TM ;let it register
        high SHFCLK ;load value to shift register
        pauseus TM ;let it register
        low SHFCLK
        if bit6=1 then ;decide to load a 1 or 0 to the shift register
            high SDI
            else
                low SDI
        endif
        pauseus TM ;let it register
        high SHFCLK ;load value to shift register
        pauseus TM ;let it register
        low SHFCLK
        if bit7=1 then ;decide to load a 1 or 0 to the shift register
            high SDI
            else
                low SDI
        endif
        pauseus TM ;let it register
        high SHFCLK ;load value to shift register
        pauseus TM ;let it register
        low SHFCLK
        if bit8=1 then ;decide to load a 1 or 0 to the shift register
            high SDI
            else
                low SDI
        endif
        pauseus TM ;let it register
        high SHFCLK ;load value to shift register
        pauseus TM ;let it register
        low SHFCLK
        if bit9=1 then ;decide to load a 1 or 0 to the shift register
            high SDI
            else
                low SDI
        endif
        pauseus TM ;let it register
        high SHFCLK ;load value to shift register
        pauseus TM ;let it register
        low SHFCLK
        if bit10=1 then ;decide to load a 1 or 0 to the shift register
            high SDI
            else
                low SDI
        endif
        pauseus TM ;let it register
        high SHFCLK ;load value to shift register
        pauseus TM ;let it register
        low SHFCLK
        if bit11=1 then ;decide to load a 1 or 0 to the shift register
            high SDI
            else
                low SDI
        endif
        pauseus TM ;let it register
        high SHFCLK ;load value to shift register
        pauseus TM ;let it register
        low SHFCLK
        pauseus TM ;let it register
        high LCHCLK ;load shift register to the output
        pauseus TM ;let it register
        low LCHCLK
        pauseus TM ;let it register
        low nWR ;put it on the PDSP2112
        pauseus TM ;let it register
        high nWR ;remove access from the display
        pauseus TM ;let it register
    
;*********************************************************;
;*              <- END OF PDSP PROGRAM ->                *;
;*********************************************************;
;*********************************************************;
;* Version 1.0 Supercap2F                                *;
;*-------------------------------------------------------*;
;* Update list:                                          *;
;* 1) - Code Complete - Supercap2F - 10/28/2014          *;
;* 2) - Simplified the code - Supercap2F -10/28/2014     *;
;*                                                       *;
;*                                                       *;
;*                                                       *;
;*********************************************************;

Thanks Steve! :)
Dan
 

KrisBlueNZ

Sadly passed away in 2015
Yes, you've figured out the overlap between the bit, byte and word variables. Your "Hello" code is loading bit patterns for the letters into w0 then calling the display subroutine, which accesses the bits individually as bit0, bit1, etc.

You can shorten the display subroutine by using a loop. You need another variable (byte-sized) for the loop counter. Each time through the loop, you set SDI according to the state of bit0 and toggle SHFCLK, then you shift all the bits down, so the value that was in b1 is now in b0, and so on. You can do this bit-shifting magically with a single statement: "let w0 = w0 / 2". I'm sure you can figure out why this will work. Then you decrement your loop counter and loop if it's not zero. (I think PICAXE has FOR or WHILE loops, doesn't it?)
 
You can shorten the display subroutine by using a loop. You need another variable (byte-sized) for the loop counter. Each time through the loop, you set SDI according to the state of bit0 and toggle SHFCLK, then you shift all the bits down, so the value that was in b1 is now in b0, and so on. You can do this bit-shifting magically with a single statement: "let w0 = w0 / 2". I'm sure you can figure out why this will work. Then you decrement your loop counter and loop if it's not zero. (I think PICAXE has FOR or WHILE loops, doesn't it?)
I wondered if there might be a way to make that repeated code simpler! :) That w0=w0/2 bit shift thing is super cool! Here's the code updated to have it:
Code:
;*********************************************************;
;*             <- START OF PDSP PROGRAM ->               *;
;*********************************************************;
;*********************************************************;
;* This program displays 'Hello!' on the PDSP2112        *;
;*********************************************************;

;***********************PIN_LAYOUT************************;
;*   PIN___FUNCTION || PIN___FUNCTION || PIN___FUNCTION  *;
;*   C.4    -CE     || C.2    -FL     || C.1    -WR      *;
;*   C.0    -RST    || B.2   SHFCLK 11|| B.3   LCHCLK 12 *;
;*   B.4   SDI      ||                ||                 *;
;*********************************************************;
;*********************************************************;
;* This section is for renaming variables and constants  *;
;*********************************************************;
symbol nCE=c.4
symbol nRST=c.0
symbol SDI=b.4
symbol nFL=c.2
symbol SHFCLK=b.2
symbol nWR=c.1
symbol LCHCLK=b.3
symbol TM=2 ;this will make all delays 5.7uS

;*********************************************************;
;* This is the main code which was made so it would      *;
;* be easy to change what's on the display               *;
;*********************************************************;

main: ;make all variables equal to zero only done once
    let bit1=0
    let bit2=0
    let bit3=0
    let bit4=0
    let bit5=0
    let bit6=0
    let bit7=0
    let bit8=0
    let bit9=0
    let bit10=0
    let bit11=0
    let bit12=0
    let b10=0
    goto start
start:
    low SHFCLK,LCHCLK,SDI
    high nCE,nWR,nRST,nFL ;a do nothing state
    pauseus TM ;let it register
    low nRST ;start the clear process
    pauseus TM ;let it register
    high nRST ;disable the rest pin
    pauseus TM ;let it register
    low nCE ;get access to the display
    do ;start endless loop
        let w0=2072 ;let w0=2072=100000011000='H'
        gosub display
        let w0=1196 ;let w0=1196=010010101100='e'
        gosub display
        let w0=3132 ;let w0=3132=110000111100='l'
        gosub display
        let w0=572 ;let w0=572=001000111100='l'
        gosub display
        let w0=2812 ;let w0=2812=101011111100='o'
        gosub display
        let w0=1668 ;let w0=1668=011010000100='!'
        gosub display
    loop until b10=0 ;endless loop
  
    ;***************************************************;
    ;* this stores the data above in the shift         *;
    ;* register/display.                               *;
    ;***************************************************;
    display:
        let b2=0 ;start loop value
        do ;start loop
            if bit0=1 then
                high SDI
            else
                low SDI
            endif
            pauseus TM ;let it register
            high SHFCLK ;load value to shift register
            pauseus TM ;let it register
            low SHFCLK
            let w0=w0/2 ;shift value down one place
            inc b2 ;let b2=b2+1 so the loop will work right
        loop until b2=11
        pauseus TM ;let it register
        high LCHCLK ;load shift register to the output
        pauseus TM ;let it register
        low LCHCLK
        pauseus TM ;let it register
        low nWR ;put it on the PDSP2112
        pauseus TM ;let it register
        high nWR ;remove access from the display
        pauseus TM ;let it register
        return

;*********************************************************;
;*              <- END OF PDSP PROGRAM ->                *;
;*********************************************************;

;*******************************************************************;
;* Version 1.0 Supercap2F                                          *;
;*-----------------------------------------------------------------*;
;* Update list:                                                    *;
;* 1) - Code Complete - Supercap2F - 10/28/2014                    *;
;* 2) - Simplified the main code - Supercap2F - 10/28/2014         *;
;* 3) - Simplified the display code - Supercap2F - 10/28/2014      *;
;*                                                                 *;
;*                                                                 *;
;*******************************************************************;
What do ya think? I think it might be time to move to breadboard! :D

Thanks Kris! :)
Dan
 

KrisBlueNZ

Sadly passed away in 2015
That looks good Dan!

The initialisation code can just say w0 = 0 instead of setting bit0~bit12 to 0 individually.

I think you should be able to change the "if bit0=1 then high SDI else low SDI" to something straightforward like "let SDI = bit0". Not sure though.
 
The initialisation code can just say w0 = 0 instead of setting bit0~bit12 to 0 individually.

I think you should be able to change the "if bit0=1 then high SDI else low SDI" to something straightforward like "let SDI = bit0". Not sure though.
Ahh yes, I missed that. Code updated to have it. :) I tried the "let SDI=bit0" like you said, but it gave me an error. :confused: Here's the code:
Code:
;*********************************************************;
;*             <- START OF PDSP PROGRAM ->               *;
;*********************************************************;
;*********************************************************;
;* This program displays 'Hello!' on the PDSP2112        *;
;*********************************************************;

;***********************PIN_LAYOUT************************;
;*   PIN___FUNCTION || PIN___FUNCTION || PIN___FUNCTION  *;
;*   C.4    -CE     || C.2    -FL     || C.1    -WR      *;
;*   C.0    -RST    || B.2   SHFCLK 11|| B.3   LCHCLK 12 *;
;*   B.4   SDI      ||                ||                 *;
;*********************************************************;
;*********************************************************;
;* This section is for renaming variables and constants  *;
;*********************************************************;
symbol nCE=c.4
symbol nRST=c.0
symbol SDI=b.4
symbol nFL=c.2
symbol SHFCLK=b.2
symbol nWR=c.1
symbol LCHCLK=b.3
symbol TM=2 ;this will make all delays 5.7uS

;*********************************************************;
;* This is the main code which was made so it would      *;
;* be easy to change what's on the display               *;
;*********************************************************;

main: ;make all variables equal to zero only done once
    let w0=0
    let b2=0
    goto start
start:
    low SHFCLK,LCHCLK,SDI
    high nCE,nWR,nRST,nFL ;a do nothing state
    pauseus TM ;let it register
    low nRST ;start the clear process
    pauseus TM ;let it register
    high nRST ;disable the rest pin
    pauseus TM ;let it register
    low nCE ;get access to the display
    do ;start endless loop
        let w0=2072 ;let w0=2072=100000011000='H'
        gosub display
        let w0=1196 ;let w0=1196=010010101100='e'
        gosub display
        let w0=3132 ;let w0=3132=110000111100='l'
        gosub display
        let w0=572 ;let w0=572=001000111100='l'
        gosub display
        let w0=2812 ;let w0=2812=101011111100='o'
        gosub display
        let w0=1668 ;let w0=1668=011010000100='!'
        gosub display
    loop until b10=0 ;endless loop

    ;***************************************************;
    ;* this stores the data above in the shift         *;
    ;* register/display.                               *;
    ;***************************************************;
    display:
        let b2=0 ;start loop value
        do ;start loop
            if bit0=1 then
                high SDI
            else
                low SDI
            endif
            pauseus TM ;let it register
            high SHFCLK ;load value to shift register
            pauseus TM ;let it register
            low SHFCLK
            let w0=w0/2 ;shift value down one place
            inc b2 ;let b2=b2+1 so the loop will work right
        loop until b2=11
        pauseus TM ;let it register
        high LCHCLK ;load shift register to the output
        pauseus TM ;let it register
        low LCHCLK
        pauseus TM ;let it register
        low nWR ;put it on the PDSP2112
        pauseus TM ;let it register
        high nWR ;remove access from the display
        pauseus TM ;let it register
        return

;*********************************************************;
;*              <- END OF PDSP PROGRAM ->                *;
;*********************************************************;

;*******************************************************************;
;* Version 1.0 Supercap2F                                          *;
;*-----------------------------------------------------------------*;
;* Update list:                                                    *;
;* 1) - Code Complete - Supercap2F - 10/28/2014                    *;
;* 2) - Simplified the main code - Supercap2F - 10/28/2014         *;
;* 3) - Simplified the display code - Supercap2F - 10/29/2014      *;
;* 4) - Updated the veriables initialisation - Supercap2F - 10/29/2014  *;
;*                                                                 *;
;*******************************************************************;
Anything else you can spot? :)
Dan
 

KrisBlueNZ

Sadly passed away in 2015
There's no actual need to initialise w0 and b2. They are both set before they are used.

When you set w0 to various values - 2072, 1196, 3132 etc - you can actually specify the values in binary using a '%' prefix: w0 = %100000011000 ; 'H'

Let's look at the mapping of the bits in those values. The first four bits specify the position for the character to be displayed at, right? But the bits seem to be backwards. I would expect the first bit to correspond to A3 and the fourth bit to correspond to A0. Then the other eight bits specify the character to write. Are they in the right order? You can re-order those bits by changing the hardware, or by sending the bits in the opposite order inside the display subroutine.

How about splitting up the display subroutine's parameter into a position byte and a character byte. This would make the display subroutine easier to use, and make the code clearer. Instead of converting "H at position 1" into %100000011000, you could just say b0 = 1 (position) and b1 = "H" (character). That makes it easier to follow the code, easier to write it, and easier to change it without making mistakes.

Separating the character and position into separate variables also makes it a lot easier to implement a scrolling display, if you want to do that in future.

The PICAXE programming "language" and environment are pretty simple and not very well designed, but you can improve your program's robustness in various ways. One weakness of the environment is the global variables. It's easy to double-book a variable - i.e. use it for two different things in such a way that when you call a subroutine, a variable that you were relying on gets overwritten. The b2 variable is a good example here.

A simple comment like "Destroys b2" in the display subroutine can help, but you can also explicitly allocate and name variables early on in your program, using comments to say which subroutines and code sections use the variable. For example you could say "'SYMBOL display_bit_looper b2". Have a look at the PICAXE code I wrote for your chicken coop door controller to see how I documented the variable allocation there.
 
Wow Kris! You really are the code master like Adam said! :)
There's no actual need to initialise w0 and b2. They are both set before they are used.
Yeah, I had a feeling that's the way it worked. But having them initialized does help me keep track of what variables have been used.
When you set w0 to various values - 2072, 1196, 3132 etc - you can actually specify the values in binary using a '%' prefix: w0 = %100000011000 ; 'H'

Let's look at the mapping of the bits in those values. The first four bits specify the position for the character to be displayed at, right? But the bits seem to be backwards. I would expect the first bit to correspond to A3 and the fourth bit to correspond to A0. Then the other eight bits specify the character to write. Are they in the right order? You can re-order those bits by changing the hardware, or by sending the bits in the opposite order inside the display subroutine.
Yeah, I guess it would make more since to have first bit to correspond to A3 and the fourth bit to correspond to A0, should I switch them around in the schematic? Should I switch around D0-D7 too?
How about splitting up the display subroutine's parameter into a position byte and a character byte. This would make the display subroutine easier to use, and make the code clearer. Instead of converting "H at position 1" into %100000011000, you could just say b0 = 1 (position) and b1 = "H" (character). That makes it easier to follow the code, easier to write it, and easier to change it without making mistakes.

Separating the character and position into separate variables also makes it a lot easier to implement a scrolling display, if you want to do that in future.
Ahh, yes! That would make the code more reader friendly. :) But shouldn't we make b0 equal the character and b1 equal the position? Because if we don't... Well let's say b0 equals the position and it's position one (0001) the byte is really 8 bits so it really equals 00000001. Then we add the character (say 00011000) so w0 would equal 0001100000000001 (since b0 comes before b1) which would be wrong. But if we make b1 equal the position it would be 0000000100011000 in other words 000100011000.
Am I thinking right? Or am I totally off? :p:D
The PICAXE programming "language" and environment are pretty simple and not very well designed, but you can improve your program's robustness in various ways. One weakness of the environment is the global variables. It's easy to double-book a variable - i.e. use it for two different things in such a way that when you call a subroutine, a variable that you were relying on gets overwritten. The b2 variable is a good example here.

A simple comment like "Destroys b2" in the display subroutine can help, but you can also explicitly allocate and name variables early on in your program, using comments to say which subroutines and code sections use the variable. For example you could say "'SYMBOL display_bit_looper b2". Have a look at the PICAXE code I wrote for your chicken coop door controller to see how I documented the variable allocation there.
OK, will try and edit the variables names/comments better in the next code update. :)

Thanks Kris! :)
Dan
 

KrisBlueNZ

Sadly passed away in 2015
It's better to keep track of the used/unused variables in a separate section before the code, using (for PICAXE) the SYMBOL statement to allocate them.

It's traditional (but not universal) for serial interfaces to send data LSB (least significant bit) first. That's how your code works at the moment. So you could keep your code the same, and reverse the bit allocations in hardware, yes. But you don't have to. A few comments in your code will clarify what the hardware does and how the bits are mapped to the data and address signals for the display module.

You're probably right about the byte ordering, and that makes sense if you're sending all 12 bits in a single loop, accessing them as w0. I was thinking it might be slightly clearer for the display subroutine to send eight bits from the character variable in one loop, then send the four bits from the position variable in a separate loop. But there's no need to do it that way.

Also now that you're not accessing w0 as separate bits, you could use w2 (aka b4 and b5) instead of w0, so those bits are available for possible future use, instead of being unusable for no good reason.

You're welcome :)
 
Last edited:
Well, that's shorter and nicer code. Good one SuperCap2F!
Hey it's not me, I'm just doing what Kris said. :)
It's better to keep track of the used/unused variables in a separate section before the code, using (for PICAXE) the SYMBOL statement to allocate them.
OK, got it.
It's traditional (but not universal) for serial interfaces to send data LSB (least significant bit) first. That's how your code works at the moment. So you could keep your code the same, and reverse the bit allocations in hardware, yes. But you don't have to. A few comments in your code will clarify what the hardware does and how the bits are mapped to the data and address signals for the display module.

You're probably right about the byte ordering, and that makes sense if you're sending all 12 bits in a single loop, accessing them as w0. I was thinking it might be slightly clearer for the display subroutine to send eight bits from the character variable in one loop, then send the four bits from the position variable in a separate loop. But there's no need to do it that way.

Also now that you're not accessing w0 as separate bits, you could use w2 (aka b4 and b5) instead of w0, so those bits are available for possible future use, instead of being unusable for no good reason.
I thought right now I was sending it MSB first? The way it's set up now it sends 'H' as 100000011000 which would be 1000 as the address:
Code:
1248-1248...
1000-00011000
|--|
location 
     |------|
     Letter
| LBS       
     | LBS
Is that right? Or am I off? I will change w0 to w2 like you said, when I post the new code. :)
Dan
 

KrisBlueNZ

Sadly passed away in 2015
Your code in the display subroutine first sends the LSB of the value you provide. This bit is in bit0. Then it divides w0 by 2, which shifts all the bits down in w2, so the value that was in bit1 is now in bit0, then it loops.

So it sends the bits in w0 starting with the LSB and ending with bit eleven, i.e. it sends LSB first.

I suggest we send all sixteen bits of w0, LSB first, and draw up a mapping of bits in the w0 value to Qx outputs on U1 and U2.

Whichever bit you send first will propagate furthest through the shift registers, and will end up on U2.QH. The next bit will be on U2.QG, and so on. So the bit mapping from w0 (or w2 as it will become) to outputs is:
Code:
F E D C B A 9 8 7 6 5 4 3 2 1 0  (bits in w2)
7 6 5 4 3 2 1 0 . . . . . . . .  (bits in b5)
. . . . . . . . 7 6 5 4 3 2 1 0  (bits in b4)
* . . . . . . . . . . . . . . .  U1.QA - available for future use
. * . . . . . . . . . . . . . .  U1.QB: -CE to PDSP2110
. . * . . . . . . . . . . . . .  U1.QC: -RST to PDSP2110
. . . * . . . . . . . . . . . .  U1.QD: -FL to PDSP2110
. . . . * * * * . . . . . . . .  Character position:
. . . . * . . . . . . . . . . .  U1.QE: char position, bit 3 (A3 to PDSP2110)
. . . . . * . . . . . . . . . .  U1.QF: char position, bit 2 (A2 to PDSP2110)
. . . . . . * . . . . . . . . .  U1.QG: char position, bit 1 (A1 to PDSP2110)
. . . . . . . * . . . . . . . .  U1.QH: char position, bit 0 (A0 to PDSP2110)
. . . . . . . . * * * * * * * *  Character:
. . . . . . . . * . . . . . . .  U2.QA: character, bit 7 (D7 to PDSP2110)
. . . . . . . . . * . . . . . .  U2.QB: character, bit 6 (D6 to PDSP2110)
. . . . . . . . . . * . . . . .  U2.QC: character, bit 5 (D5 to PDSP2110)
. . . . . . . . . . . * . . . .  U2.QD: character, bit 4 (D4 to PDSP2110)
. . . . . . . . . . . . * . . .  U2.QE: character, bit 3 (D3 to PDSP2110)
. . . . . . . . . . . . . * . .  U2.QF: character, bit 2 (D2 to PDSP2110)
. . . . . . . . . . . . . . * .  U2.QG: character, bit 1 (D1 to PDSP2110)
. . . . . . . . . . . . . . . *  U2.QH: character, bit 0 (D0 to PDSP2110)
So I've suggested redefining the connection between the shift registers and the PDSP2110, and I've sneaked in -CE, -RST and -FL being driven from the shift registers as well. This is because those signals don't need to change very often. Only -WR needs to be pulsed briefly, to execute the write operation once the other states are set up. The initial reset only needs to be done once, and -FL is tied in with the address and data lines anyway.

You might want or need to keep -CE driven directly from the micro, so you can quickly deselect the PDSP2110 when the access has finished, since you may find that you need to raise -CE in between writes for the PDSP to work properly. (Your code currently leaves -CE low in between accesses to different addresses in the PDSP2110, but this may not work properly when you test it.)

Once you change to using w2 instead of w0, in your loop in the display subroutine you will have to change the test "if bit0 = 1 then high SDI else low SDI endif" to "if (w2 & 1) = 1 then high SDI else low SDI endif" because you can no longer access bit 0 of the 16-bit data value as a bit variable.
 
Ahh, I see! Sorry it took so long! :p
So I've suggested redefining the connection between the shift registers and the PDSP2110, and I've sneaked in -CE, -RST and -FL being driven from the shift registers as well. This is because those signals don't need to change very often. Only -WR needs to be pulsed briefly, to execute the write operation once the other states are set up. The initial reset only needs to be done once, and -FL is tied in with the address and data lines anyway.

You might want or need to keep -CE driven directly from the micro, so you can quickly deselect the PDSP2110 when the access has finished, since you may find that you need to raise -CE in between writes for the PDSP to work properly. (Your code currently leaves -CE low in between accesses to different addresses in the PDSP2110, but this may not work properly when you test it.)
K, no probs. So should we just leave -CE how it is now, and if it doesn't work worry about it then? :D
Once you change to using w2 instead of w0, in your loop in the display subroutine you will have to change the test "if bit0 = 1 then high SDI else low SDI endif" to "if (w2 & 1) = 1 then high SDI else low SDI endif" because you can no longer access bit 0 of the 16-bit data value as a bit variable.
I tried using the "if (w2 & 1) = 1 then high SDI else low SDI endif" thing, but it gave me an "syntax" error on the "if (w2 & 1)" part. :confused: I can't think of anything to to but use w0 instead... Do you know of anything to do? Here's the code:
Code:
;*********************************************************;
;*             <- START OF PDSP PROGRAM ->                 *;
;*********************************************************;
;*********************************************************;
;* This program displays 'Hello!' on the PDSP2112        *;
;*********************************************************;
;F E D C B A 9 8 7 6 5 4 3 2 1 0  (bits in w2)
;7 6 5 4 3 2 1 0 . . . . . . . .  (bits in b5)
;. . . . . . . . 7 6 5 4 3 2 1 0  (bits in b4)
;* . . . . . . . . . . . . . . .  U1.QA - available for future use
;. * . . . . . . . . . . . . . .  U1.QB: -CE to PDSP2110
;. . * . . . . . . . . . . . . .  U1.QC: -RST to PDSP2110
;. . . * . . . . . . . . . . . .  U1.QD: -FL to PDSP2110
;. . . . * * * * . . . . . . . .  Character position:
;. . . . * . . . . . . . . . . .  U1.QE: char position, bit 3 (A3 to PDSP2110)
;. . . . . * . . . . . . . . . .  U1.QF: char position, bit 2 (A2 to PDSP2110)
;. . . . . . * . . . . . . . . .  U1.QG: char position, bit 1 (A1 to PDSP2110)
;. . . . . . . * . . . . . . . .  U1.QH: char position, bit 0 (A0 to PDSP2110)
;. . . . . . . . * * * * * * * *  Character:
;. . . . . . . . * . . . . . . .  U2.QA: character, bit 7 (D7 to PDSP2110)
;. . . . . . . . . * . . . . . .  U2.QB: character, bit 6 (D6 to PDSP2110)
;. . . . . . . . . . * . . . . .  U2.QC: character, bit 5 (D5 to PDSP2110)
;. . . . . . . . . . . * . . . .  U2.QD: character, bit 4 (D4 to PDSP2110)
;. . . . . . . . . . . . * . . .  U2.QE: character, bit 3 (D3 to PDSP2110)
;. . . . . . . . . . . . . * . .  U2.QF: character, bit 2 (D2 to PDSP2110)
;. . . . . . . . . . . . . . * .  U2.QG: character, bit 1 (D1 to PDSP2110)
;. . . . . . . . . . . . . . . *  U2.QH: character, bit 0 (D0 to PDSP2110)

;***********************PIN_LAYOUT************************;
;*   PIN___FUNCTION || PIN___FUNCTION || PIN___FUNCTION  *;
;*   C.0   SDI      || C.1   LCHCLK 12|| C.2   SHFCLK 11 *;
;*   B.1   -WR      ||                ||                 *;
;*********************************************************;
;*********************************************************;
;* This section is for renaming variables and constants   *;
;*********************************************************;
symbol SDI=c.0
symbol SHFCLK=c.2
symbol nWR=b.1
symbol LCHCLK=c.1
symbol TM=2 ;this will make all delays 5.7uS

;*********************************************************;
;* This is the main code which was made so it would      *;
;* be easy to change what's on the display               *;
;*********************************************************;
main:
    let b5=%01110000 ;high nCE,nRST,nFL
    high nWR
    low SHFCLK,LCHCLK,SDI
    gosub display ;a do nothing state
    let b5=%01010000 ;low nRST
    gosub display ;start the clear process
    let b5=%01110000 ;high nRST
    gosub display ;disable the reset pin
    let b5=%00110000 ;low nCE
    gosub display ;get access to the display
    do ;start endless loop
        let b5=%00110001 ;high nFL, nRST. address #1
        let b4=%00011000 ;character 'H'
        gosub display
        gosub load_on_screen
        let b5=%00110010 ;high nFL, nRST. address #2
        let b4=%01100101 ;character 'e'
        gosub display
        gosub load_on_screen
        let b5=%00110011 ;high nFL, nRST. address #3
        let b4=%01101100 ;character 'l'
        gosub display
        gosub load_on_screen
        let b5=%00110100 ;high nFL, nRST. address #4
        let b4=%01101100 ;character 'l'
        gosub display
        gosub load_on_screen
        let b5=%00110101 ;high nFL, nRST. address #5
        let b4=%01101111 ;character 'l'
        gosub display
        gosub load_on_screen
        let b5=%00110011 ;high nFL, nRST. address #3
        let b4=%00100001 ;character '!'
        gosub display
        gosub load_on_screen
    loop until b10=10 ;endless loop
   
    ;***************************************************;
    ;* this stores the data above in the shift         *;
    ;* register.                                       *;
    ;***************************************************;
    display:
        let b2=0 ;start loop value
        do ;start loop
            if (w2 & 1)=1 then ;ERROR HERE!!
                high SDI
            else
                low SDI
            endif
            pauseus TM ;let it register
            high SHFCLK ;load value to shift register
            pauseus TM ;let it register
            low SHFCLK
            let w2=w2/2 ;shift value down one place
            inc b2 ;let b2=b2+1 so the loop will work right
        loop until b2=16
        pauseus TM ;let it register
        high LCHCLK ;load shift register to the output
        pauseus TM ;let it register
        low LCHCLK
        pauseus TM ;let it register
        return
;*********************************************************;
;* This loads the data in the shift register to the      *;
;* screen.                           *;
;*********************************************************;
load_on_screen:
        pauseus TM ;let it register
        low nWR ;put it on the PDSP2112
        pauseus TM ;let it register
        high nWR ;remove access from the display
        pauseus TM ;let it register
        return

;*********************************************************;
;*              <- END OF PDSP PROGRAM ->                *;
;*********************************************************;

;*******************************************************************;
;* Version 1.0 Supercap2F                                          *;
;*-----------------------------------------------------------------*;
;* Update list:                                                    *;
;* 1) - Code Complete - Supercap2F - 10/28/2014                    *;
;* 2) - Simplified the main code - Supercap2F - 10/28/2014         *;
;* 3) - Simplified the display code - Supercap2F - 10/28/2014      *;
;* 4) - Changed pin layout. And made code more robust              *;
;*      Supercap2F - 10/30/2014                      *;
;*                                       *;
;*******************************************************************;
And the altered schematic (I changed it around some and I also messed with some settings in Diptrace to make it look better):
PDSPSCH_10_30_2014_#1.jpg
Thanks very much Kris! :)
Dan
 
Last edited:

KrisBlueNZ

Sadly passed away in 2015
That schematic looks great! Nice work there. Only four pins used for the display interface. I don't think you'll get much less than that!

Re isolating bit 0 of the data word. The "if (w2 & 1) = 1" is not allowed in PICAXE language because it's too complicated! There might be ways around it, but it's simplest to go back to using w0 (r0 for the character and r1 for the position and control signals) and testing bit0.

I'm not sure how best to deal with -CE. Do you have your code working on a breadboard prototype?

Now that we're controlling -RST from the shift register, your startup code needs to call the display subroutine to send values to the shift register, to bring -RST low then return it high again at startup. But the display subroutine also pulses -WR low. I notice that you set the four address bits to all zeros for that case, and I guess that will cause a dummy write because address 0000 doesn't do anything, right? So it probably won't cause any problems, but it's not strictly right.

I suggest you add another subroutine called displaychar, and rename the existing subroutine to write_sr (write shift register) or something similar. displaychar needs to call write_sr, but write_sr should only write the 16-bit data to the shift register; move the code that pulses -WR low from the write_sr subroutine into the displaychar subroutine.

So during initialisation you can call write_sr to write values to the control signals without pulsing -WR, and to write a character, you call displaychar, which calls write_sr to write the 16-bit data to the shift register, then pulses -WR low briefly.
 
Re isolating bit 0 of the data word. The "if (w2 & 1) = 1" is not allowed in PICAXE language because it's too complicated! There might be ways around it, but it's simplest to go back to using w0 (r0 for the character and r1 for the position and control signals) and testing bit0.
Yeah, it bugged me all night trying to think of a way to do it in my sleep. Lol!
I'm not sure how best to deal with -CE. Do you have your code working on a breadboard prototype?
No I don’t have it on a breadboard yet. Should I lay it out now?
Now that we're controlling -RST from the shift register, your startup code needs to call the display subroutine to send values to the shift register, to bring -RST low then return it high again at startup. But the display subroutine also pulses -WR low. I notice that you set the four address bits to all zeros for that case, and I guess that will cause a dummy write because address 0000 doesn't do anything, right? So it probably won't cause any problems, but it's not strictly right.
Did you see I changed the display subroutine? I put the part that pluses –WR low in a new subroutine called “load_on_screen” and I only called it when I was changing the characters.
I suggest you add another subroutine called displaychar, and rename the existing subroutine to write_sr (write shift register) or something similar. displaychar needs to call write_sr, but write_sr should only write the 16-bit data to the shift register; move the code that pulses -WR low from the write_sr subroutine into the displaychar subroutine.
This is pretty much what I did when I added the “load_on_screen” subroutine. Sorry I should have said something about it in post #37. o_O It is a little different then what you suggested, so have a look over it and tell me what you think. :)

Code updated to have w2 changed back to w0, here it is:
Code:
;*********************************************************;
;*             <- START OF PDSP PROGRAM ->               *;
;*********************************************************;
;*********************************************************;
;* This program displays 'Hello!' on the PDSP2112        *;
;*********************************************************;
;F E D C B A 9 8 7 6 5 4 3 2 1 0  (bits in w0)
;7 6 5 4 3 2 1 0 . . . . . . . .  (bits in b1)
;. . . . . . . . 7 6 5 4 3 2 1 0  (bits in b0)
;* . . . . . . . . . . . . . . .  U1.QA - available for future use
;. * . . . . . . . . . . . . . .  U1.QB: -CE to PDSP2110
;. . * . . . . . . . . . . . . .  U1.QC: -RST to PDSP2110
;. . . * . . . . . . . . . . . .  U1.QD: -FL to PDSP2110
;. . . . * * * * . . . . . . . .  Character position:
;. . . . * . . . . . . . . . . .  U1.QE: char position, bit 3 (A3 to PDSP2110)
;. . . . . * . . . . . . . . . .  U1.QF: char position, bit 2 (A2 to PDSP2110)
;. . . . . . * . . . . . . . . .  U1.QG: char position, bit 1 (A1 to PDSP2110)
;. . . . . . . * . . . . . . . .  U1.QH: char position, bit 0 (A0 to PDSP2110)
;. . . . . . . . * * * * * * * *  Character:
;. . . . . . . . * . . . . . . .  U2.QA: character, bit 7 (D7 to PDSP2110)
;. . . . . . . . . * . . . . . .  U2.QB: character, bit 6 (D6 to PDSP2110)
;. . . . . . . . . . * . . . . .  U2.QC: character, bit 5 (D5 to PDSP2110)
;. . . . . . . . . . . * . . . .  U2.QD: character, bit 4 (D4 to PDSP2110)
;. . . . . . . . . . . . * . . .  U2.QE: character, bit 3 (D3 to PDSP2110)
;. . . . . . . . . . . . . * . .  U2.QF: character, bit 2 (D2 to PDSP2110)
;. . . . . . . . . . . . . . * .  U2.QG: character, bit 1 (D1 to PDSP2110)
;. . . . . . . . . . . . . . . *  U2.QH: character, bit 0 (D0 to PDSP2110)

;***********************PIN_LAYOUT************************;
;*   PIN___FUNCTION || PIN___FUNCTION || PIN___FUNCTION  *;
;*   C.0   SDI      || C.1   LCHCLK 12|| C.2   SHFCLK 11 *;
;*   B.1   -WR      ||                ||                 *;
;*********************************************************;
;*********************************************************;
;* This section is for renaming variables and constants  *;
;*********************************************************;
symbol SDI=c.0
symbol SHFCLK=c.2
symbol nWR=b.1
symbol LCHCLK=c.1
symbol TM=2 ;this will make all delays 5.7uS

;*********************************************************;
;* This is the main code which was made so it would      *;
;* be easy to change what's on the display               *;
;*********************************************************;
main:
    let b1=%01110000 ;high nCE,nRST,nFL
    high nWR
    low SHFCLK,LCHCLK,SDI
    gosub display ;a do nothing state
    let b1=%01010000 ;low nRST
    gosub display ;start the clear process
    let b1=%01110000 ;high nRST
    gosub display ;disable the reset pin
    let b1=%00110000 ;low nCE
    gosub display ;get access to the display
    do ;start endless loop
        let b1=%00110001 ;high nFL, nRST. address #1
        let b0=%00011000 ;character 'H'
        gosub display
        gosub load_on_screen
        let b1=%00110010 ;high nFL, nRST. address #2
        let b0=%01100101 ;character 'e'
        gosub display
        gosub load_on_screen
        let b1=%00110011 ;high nFL, nRST. address #3
        let b0=%01101100 ;character 'l'
        gosub display
        gosub load_on_screen
        let b1=%00110100 ;high nFL, nRST. address #4
        let b0=%01101100 ;character 'l'
        gosub display
        gosub load_on_screen
        let b1=%00110101 ;high nFL, nRST. address #5
        let b0=%01101111 ;character 'l'
        gosub display
        gosub load_on_screen
        let b1=%00110011 ;high nFL, nRST. address #3
        let b0=%00100001 ;character '!'
        gosub display
        gosub load_on_screen
    loop until b10=10 ;endless loop
  
    ;***************************************************;
    ;* this stores the data above in the shift         *;
    ;* register.                                       *;
    ;***************************************************;
    display:
        let b2=0 ;start loop value
        do ;start loop
            if bit1=1 then
                high SDI
            else
                low SDI
            endif
            pauseus TM ;let it register
            high SHFCLK ;load value to shift register
            pauseus TM ;let it register
            low SHFCLK
            let w2=w2/2 ;shift value down one place
            inc b2 ;let b2=b2+1 so the loop will work right
        loop until b2=16
        pauseus TM ;let it register
        high LCHCLK ;load shift register to the output
        pauseus TM ;let it register
        low LCHCLK
        pauseus TM ;let it register
        return
;*********************************************************;
;* This loads the data in the shift register to the      *;
;* screen.                                               *;
;*********************************************************;
load_on_screen:
        pauseus TM ;let it register
        low nWR ;put it on the PDSP2112
        pauseus TM ;let it register
        high nWR ;remove access from the display
        pauseus TM ;let it register
        return

;*********************************************************;
;*              <- END OF PDSP PROGRAM ->                *;
;*********************************************************;

;*******************************************************************;
;* Version 1.0 Supercap2F                                          *;
;*-----------------------------------------------------------------*;
;* Update list:                                                    *;
;* 1) - Code Complete - Supercap2F - 10/28/2014                    *;
;* 2) - Simplified the main code - Supercap2F - 10/29/2014         *;
;* 3) - Simplified the display code - Supercap2F - 10/29/2014      *;
;* 4) - Changed pin layout. And made code more robust              *;
;*      Supercap2F - 10/30/2014                                    *;
;* 5) - Changed varaibles back to how they where - Supercap2F      *;
;*      - 10/31/14                                                 *;
;*                                                                 *;
;*******************************************************************;
Dan
 

KrisBlueNZ

Sadly passed away in 2015
Sorry, I didn't notice that you'd separated out the two subroutines. That's good, though I think it would be better to call the first subroutine write_sr or something like that, not display.

Also at the start of your shift register bit loop, you are setting SDI high or low according to the state of bit1; that should be bit0.

And further on in the loop, you missed one change of w2 to w0.

And if you include "gosub write_sr" at the start of the load_on_screen subroutine, you'll only need to call one subroutine for each character you want to write.

Also, that device uses the standard ASCII character set, so you don't need to specify characters as binary constants. Instead of
let b0=%00011000 ;character 'H'
you can say
let b0 = "H"

Yes I think this would be a good time to prototype it on breadboard.
 
Top