Shop OBEX P1 Docs P2 Docs Learn Events
Demo board clock output — Parallax Forums

Demo board clock output

HasinHasin Posts: 1
edited 2009-11-28 08:28 in Propeller 1
Hi all,
I'm new to propeller thing and I need your help, please. I have propeller demo board, ay0438 circuit and LCD 7-segment display. I need to connect the demo board with ay0438. I need one port to DATA, one port for LOAD and one for CLOCK. I managed first two ports but I don't know how create a code for clock port.

Don't know if I explained it enough, but If anyone could help me I will be very happy.

Thanks for all replies

PS: Sorry for my English rolleyes.gif

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2009-11-27 12:10
    With that little information you gave, there are lots of possibilities.

    1. Do you code in SPIN or in PASM?
    2. Do you have some timing requirements/restrictions?
    3. Do you want to code it by yourself, or would you be fine with a driver that already works?
    4. Why didn't you provide the code you already have?

    On a quick glance it should be possible to use an SPI driver for that ... maybe you have to tweak it a bit - for example to limit it to 1,5MHz clock frequency.

    In general:
    I suppose you already have the datasheet for the AY0438. There you find a timing diagram which shows you when you have to set and when you have to clear the clock-pin. So, whatever your code looks like currently, find the places where you have to clear the pin and where you have to set the pin and put the right instructions there.

    In SPIN you'd do for setting or clearing that one bit:
    outa[noparse][[/noparse] CLK_PIN ]~
    outa[noparse][[/noparse] CLK_PIN ]~~

    For a general purpose PASM solution you need a mask where only the pin is set:
    dat clk_mask long 1<|CLK_PIN

    ... and then you do for setting or clearing that one bit:
    or outa, clk_mask
    andn outa, clk_mask

    This is only the easiest solution ... maybe it makes sense to use a counter to do that, maybe not ... that depends on the missing information ;o)
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-11-27 19:42
    Hello Hasin,

    nice find this chip.
    a shiftregister with latch and 32 outputs in one DIP-package.
    replaces four 74HC595'ers and suits perfect to the 32bits of a long.

    Stefan
  • SapiehaSapieha Posts: 2,964
    edited 2009-11-28 00:38
    Hi StefanL38


    I use that one to Drive leds
    MAX6954

    Regards

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nothing is impossible, there are only different degrees of difficulty.
    For every stupid question there is at least one intelligent answer.
    Don't guess - ask instead.
    If you don't ask you won't know.
    If your gonna construct something, make it·as simple as·possible yet as versatile as posible.


    Sapieha
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-11-28 08:28
    Hello Hasin,

    the AY0438-chip has a serial interface this means

    repeat
    set the data-pin to the wished value
    and then you switch the clock pin low-high-low (or maybe (high-low-high) depending on what the datasheet says

    The data-signal and clock-signal have to be switched after each other but the clocksignal-pulse must be done before
    setting the data-pin to the value of the next bit.

    Through the clock-pulse the databit is shifted in into the shiftregister

    After you finished shifting in all 32 databits
    you give one pulse on the load-pin. This signal transfers the bitvalues to the latch and the voltages on the output-pins change
    to the bitstates stored in the latch

    Come on ! Play around with the data-pin, clock-pin and the load-pin.

    I mean to learn how it works program some hardcodes pulse-sequences
    test which element of your display show up if you give a signal on the output-pin no Seg1, Seg2, Seg3 of the AY0438
    draw a little picture of these segments
    connect your display to the outputs of the AY0438

    connect the AY0438 to the prop-pins 16-18 and run the program below
    look what result you get on the AY0438-SEG-pins
    If you do the low-high-switching right you get the same bitpattern on the SEG-pins like you have coded them in the spin-code


    CON
      _clkmode      = xtal1 + pll16x                        ' use crystal x 16
      _xinfreq      = 5_000_000
    
    
      DataPin   = 16
      Clock_Pin = 17
      Load_Pin  = 18
    
      OutPut = 1
      Input  = 0
    
      Low    = 0
      High   = 1
    
    
    Pub Test_AY0438
    
      DirA[noparse][[/noparse] DataPin ]   := OutPut 'configure IO-pins as output-pins
      DirA[noparse][[/noparse] Clock_Pin ] := OutPut
      DirA[noparse][[/noparse] Load_Pin ]  := OutPut
    
    
      OutA[noparse][[/noparse] DataPin ]   := High   'set databit high = 1
    
      'create a Clock-pulse
      OutA[noparse][[/noparse] Clock_Pin ] := High
      OutA[noparse][[/noparse] Clock_Pin ] := Low
      OutA[noparse][[/noparse] Clock_Pin ] := High
      
    
      OutA[noparse][[/noparse] DataPin ]   := Low
      
      'create a Clock-pulse
      OutA[noparse][[/noparse] Clock_Pin ] := High
      OutA[noparse][[/noparse] Clock_Pin ] := Low
      OutA[noparse][[/noparse] Clock_Pin ] := High
    
    
      OutA[noparse][[/noparse] DataPin ]   := High
      
      'create a Clock-pulse
      OutA[noparse][[/noparse] Clock_Pin ] := High
      OutA[noparse][[/noparse] Clock_Pin ] := Low
      OutA[noparse][[/noparse] Clock_Pin ] := High
    
    
      'create a load-pulse
      OutA[noparse][[/noparse] Load_Pin ]   := Low
      OutA[noparse][[/noparse] Load_Pin ]   := High
      OutA[noparse][[/noparse] Load_Pin ]   := Low
    
    



    if this code switches right then the bitpattern should be
    seg1 = high
    seg2 = low
    seg3 = high

    Maybe you are thinking "ey that's far OFF of what I want to to in the end !

    SURE that's far off ! But you will reach the point that everything works MUCH faster if you understand from scratch how the chip works

    If you start at the level: "let's shift in the 32bits from a separate cog by using a downloaded object"
    you maybe stumble around for days or even weeks until everything works properly
    with a lot of help of experienced propeller-users and if another bug occures you still DON'T know where to search.

    If you understand it from scratch you will be the expert in 1 week yourself about bitshifting and bitbanging towards the AY0438-chip

    A variant to play around is to write a program that waits for a (debounced) button to be pressed before each step to create one pulse
    and have LEDs connected parallel to the AY0438-chip-data, clock and load-pins.
    Then you have a visual feedback about the logical state of the IO-pins
    and by pressing the button you can single-step through the process of how data, clock and load-signal change
    By varying the pulse-sequences of the clock from low-high-low to high-low-high and load-pulse low-high-low, high-low-high
    you will find out how it has to be done to shift in the bits the right way

    another way could be to replace the button through a serial connection that waits to receive a certain byte before
    executing the next step

    best regards

    Stefan
Sign In or Register to comment.