Shop OBEX P1 Docs P2 Docs Learn Events
Code doesn't want to configure for ViewPort — Parallax Forums

Code doesn't want to configure for ViewPort

HShankoHShanko Posts: 402
edited 2011-08-17 11:14 in Propeller 1
@ Any one,

For some reason this code seems to run OK, but I cannot get ViewPort ver 4.5.3 to configure properly. I've tried the '4-bit counter' on the board and that runs OK, but not this. I'm trying to use the Logic Analyzer mode to view some timing relationships.

Ths 'ViewPort portion of the code' was copied/pasted and modified from a program that runs OK. But not this. Probably some stupid error on my part, but I just cannot see what's not right.

''===========================================================================================
''
''   File....... LCD_24x1.spin
''   Purpose.... to bring-up a 24x1 LCD (All Elect. LED-111 a Wintek# WDC2401P-1GNNA)
''   Author..... Harley Shanko - used Jonny Mac's QuickStart demo with mods
''               Copyright (c) 2011 H Shanko
''               -- see below for terms of use
''   E-mail..... hshanko@OregonsBest.com or HarleyShanko@gmail.com
''   Started.... 31 Jul 2011, 11:04 am; used Jonny Mac's source to begin
''   Updated.... 15 Aug.2011  3:31 pm
''
'' ===========================================================================================
CON
  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000                                  ' QuickStart board uses 5MHz crystal
' _xinfreq = 6_250_000                                  ' use 6.25MHz crystal

  CLK_FREQ = ((_clkmode - xtal1) >> 6) * _xinfreq
  MS_001   = 80_000_000 / 1_000  
'  MS_001   = CLK_FREQ / 1_000
'  US_001   = CLK_FREQ / 1_000_000
' Prop 1 I/O usage (P31..P0)
  RX1  = 31
  TX1  = 30
  SDA  = 29
  SCL  = 28                           
{{ unused
  = 27
  = 26
  = 25
  = 24            }}

  LED7 = 23
  LED6 = 22
  LED5 = 21
  LED4 = 20  
  LED3 = 19
  LED2 = 18
  LED1 = 17
  LED0 = 16
{{ TV video and audio use
  = 15  ' audio use
  = 14  ' video lsb
  = 13  '   "   2nd lsb
  = 12  '   "   msb             }}
  E_LCD     = 11                ' HI = Load, on negative edge Latch
  RW_LCD    = 10                ' LO = Write, HI = Read
  RS_LCD    =  9                ' LO = Command, HI = Data
  reset_LCD =  8                ' LO = Reset, HI = reset released

  PAD7 = 7
  PAD6 = 6
  PAD5 = 5
  PAD4 = 4
  PAD3 = 3
  PAD2 = 2
  PAD1 = 1
  PAD0 = 0

  #1, HOME, GOTOXY                                     ' PST formmatting control
  #8, BKSP, TAB, LF, CLREOL, CLRDN, CR, GOTOX, GOTOY, CLS

VAR
  long stack[50], frame[400], cntDn
  byte chr

OBJ
'  term  : "fullduplexserial"    ' = FDS
'  TV    : "TV_text"             ' to be used later, maybe
  vp    : "Conduit"             ' transfers data to/from a PC; uses 1 cog
  qs    : "QuickSample"         ' captures INA, variables; uses 1 cog, samples at 20 MHz
'  dbg   : "PASDebug"            ' Include for PASD Debugger  (MUST include binary file)

PUB Main                        ' Cog 0
  vp.register(qs.sampleINA(@frame,1)) 'sample INA w/ 1 cog up to 20 MHz (MUST BE COG 0)
  optional_configure_viewport   ' optionally configure Viewport's interface
  vp.share(@cntDn,@chr) 'share memory from 'cntDn' to 'chr';   END of VP commands <<===      
   
'  Display.start(12)                                     '  "  Cog 3
'  id := cognew(@DTbus,@DTarray[0])  ' this sets up the DTbus registers for the DTbus cog 
'  id := cognew(@entry,@DTarray[0]) ' cog for DTbus R/Ws; Cog 3; PASD; CmdStatus=>StatAsm @ PAR
'  id := dbg.start(31,30,@entry) ' Include for PASD debugger (NOTE:  PASD needs a 'xxx.bin' file)
        
{{  term.start(RX1, TX1, %0000, 115_200)                  ' init FDS

  term.str(string(CLS, "QuickStart LCD test, 15 Aug.2011"))     
  waitcnt((MS_001 * 1000 +cnt))                                  }}
  initLCD
  dira[LED7..LED0]~~            ' LEDs are outputs from Prop
'  DIRA[E_LCD..PAD0]~~           ' make P0..P11 outputs on Prop   (this just a TEMP use)
  cntDn := 0
                                                       
  repeat
    if cntDn == 0               ' check if value reached zero
      cntDn := $0000_0FFF       '   if so, set to FFFh
    outa[LED7..LED0] := cntDn   ' output cntDn value to LEDs
    OUTA[PAD7..PAD0] := $0000_00FF & cntDn  ' output also to LCD's 8 lines
    chr := $00FF & cntDn
    wr_LCD
{{    term.tx(HOME)
    term.hex(cntDn, 4)
    term.tx(CR)                 }}   
    cntDn := cntDn - 1          ' decrement value
    waitcnt((MS_001 * 1000) +cnt)        ' pause to display for human eyes; ~45 ms loop time by scope

'+-------------------------------------------------------------------------------------+    
PUB optional_configure_viewport                                 ' FROM CONTROL1                                                               
  vp.config(string("var:io(bits=[all[0..29],30tx,31rx])"))
  vp.config(string("var:io,cntDn,chr")) ' show these VARs
  vp.config(string("lsa:view=io,timescale=200ns,trigger=io[23]r")) ' trig on A23 rising
  vp.config(string("edit:chr(default=5,mode=text),cntDn(mode=text)"))
  vp.config(string("start:lsa"))                                            
'+-------------------------------------------------------------------------------------+

PUB initLCD
{{  term.tx(CR)                  }}
  DIRA[E_LCD..PAD0]~~           ' make P0..P11 outputs on Prop
  OUTA[E_LCD..reset_LCD] := $1<<8     ' set E_LCD..reset_LCD (LCD control lines) LO
  waitcnt(MS_001*2100+ cnt)     ' delay about 20 ms
' OUTA[reset_LCD]~           ' release reset line
'  waitcnt(MS_001*10 + cnt)  
  chr := $1C                    ' turn on LCD driver power
  wr_LCD                        ' send command
  chr := $14                    ' turn on character display
  wr_LCD
  chr := $28                    ' set for '2 by 12 char. lines'
  wr_LCD
  chr := $4F                    ' set at darkest contrast
  wr_LCD
  chr := $E0                    ' set data address to first location
  wr_LCD
  OUTA[RS_LCD]~~                ' set RS line Hi for Data transfer
  waitcnt(MS_001*100 + cnt)  
{{  term.str(string(CLS, "initLCD done"))
  term.tx(CR)                                   }}

PUB wr_LCD                      ' enter with RS Hi for Data, LO for Commands
  OUTA[E_LCD]~~                 ' E line Hi to load value
'  waitcnt(MS_001 + cnt)
  OUTA[PAD7..PAD0] := chr       ' byte to LCD for Data/Command
'  waitcnt(MS_001 + cnt)
  OUTA[E_LCD]~                  ' drop E line to latch the value
{{    term.tx(HOME)                                       ' TEMP USE, this, next5 lines
    term.str(string("wr_LCD = "))
    term.hex(chr, 2)
    term.tx(CR)                          }}
  waitcnt(MS_001 * 10+ cnt)        ' wait for about 1 millisecond   ' 10 ms enough ???

dat

Comments

  • mojorizingmojorizing Posts: 249
    edited 2011-08-15 20:19
    Harley,
    It works for me, though I think timescale=200ns is a little quick for the other pins which are slower transitions.

    I sent you note, please check you're inbox.
  • HShankoHShanko Posts: 402
    edited 2011-08-16 09:36
    Thanks mojorizing, I can't hardly believe it, that it ran for you. OK, maybe there is something going on with VP 4.5.3. I have downloaded but not yet installed 4.6.0. It seems that when I install a later version there is always something that makes it difficult to get everything working again.

    Hope to get the install done today and give it a try. Would love to see VP working on this QS board. Yes, I may not have the timing optimum; since VP hadn't worked yet I didn't even attempt to set a better default timescale. I noticed that but it didn't matter yet. Have some non-Prop things to handle before getting back to the debugging part today/tomorrow. Ah, yes, there is always Ma
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-08-16 10:51
    Hi Harley,

    what do you see when running viewport with acode that you call "OK" and what do you see when running code that you call "not working"?

    I tested your code with ViewPort 4.5.3. First it did run. Now it doesn't anymore and I have a message "wait for trigger" in the lsa-view.

    What does this mean and how can it be made triggering all the time?

    best regards

    Stefan
  • PublisonPublison Posts: 12,366
    edited 2011-08-16 10:54
    Harley,

    I tried your code with Version 4.5.1 and 4.60. You will not get any change on the LSA , (not triggered), with your code triggering on PIN23 (LED7), as it never changes.

    I changed the trigger pin to P16 and set the time scale to 10us, and it seems to work fine.

    These tests were done on a Demo Board, as I don't have a Quick Start, (yet).
    ''===========================================================================================
    ''
    ''   File....... LCD_24x1.spin
    ''   Purpose.... to bring-up a 24x1 LCD (All Elect. LED-111 a Wintek# WDC2401P-1GNNA)
    ''   Author..... Harley Shanko - used Jonny Mac's QuickStart demo with mods
    ''               Copyright (c) 2011 H Shanko
    ''               -- see below for terms of use
    ''   E-mail..... hshanko@OregonsBest.com or HarleyShanko@gmail.com
    ''   Started.... 31 Jul 2011, 11:04 am; used Jonny Mac's source to begin
    ''   Updated.... 15 Aug.2011  3:31 pm
    ''
    '' ===========================================================================================
    CON
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000                                  ' QuickStart board uses 5MHz crystal
    ' _xinfreq = 6_250_000                                  ' use 6.25MHz crystal
    
      CLK_FREQ = ((_clkmode - xtal1) >> 6) * _xinfreq
      MS_001   = 80_000_000 / 1_000  
    '  MS_001   = CLK_FREQ / 1_000
    '  US_001   = CLK_FREQ / 1_000_000
    ' Prop 1 I/O usage (P31..P0)
      RX1  = 31
      TX1  = 30
      SDA  = 29
      SCL  = 28                           
    {{ unused
      = 27
      = 26
      = 25
      = 24            }}
    
      LED7 = 23
      LED6 = 22
      LED5 = 21
      LED4 = 20  
      LED3 = 19
      LED2 = 18
      LED1 = 17
      LED0 = 16
    {{ TV video and audio use
      = 15  ' audio use
      = 14  ' video lsb
      = 13  '   "   2nd lsb
      = 12  '   "   msb             }}
      E_LCD     = 11                ' HI = Load, on negative edge Latch
      RW_LCD    = 10                ' LO = Write, HI = Read
      RS_LCD    =  9                ' LO = Command, HI = Data
      reset_LCD =  8                ' LO = Reset, HI = reset released
    
      PAD7 = 7
      PAD6 = 6
      PAD5 = 5
      PAD4 = 4
      PAD3 = 3
      PAD2 = 2
      PAD1 = 1
      PAD0 = 0
    
      #1, HOME, GOTOXY                                     ' PST formmatting control
      #8, BKSP, TAB, LF, CLREOL, CLRDN, CR, GOTOX, GOTOY, CLS
    
    VAR
      long stack[50], frame[400], cntDn
      byte chr
    
    OBJ
    '  term  : "fullduplexserial"    ' = FDS
    '  TV    : "TV_text"             ' to be used later, maybe
      vp    : "Conduit"             ' transfers data to/from a PC; uses 1 cog
      qs    : "QuickSample"         ' captures INA, variables; uses 1 cog, samples at 20 MHz
    '  dbg   : "PASDebug"            ' Include for PASD Debugger  (MUST include binary file)
    
    PUB Main                        ' Cog 0
      vp.register(qs.sampleINA(@frame,1)) 'sample INA w/ 1 cog up to 20 MHz (MUST BE COG 0)
      optional_configure_viewport   ' optionally configure Viewport's interface
      vp.share(@cntDn,@chr) 'share memory from 'cntDn' to 'chr';   END of VP commands <<===      
       
    '  Display.start(12)                                     '  "  Cog 3
    '  id := cognew(@DTbus,@DTarray[0])  ' this sets up the DTbus registers for the DTbus cog 
    '  id := cognew(@entry,@DTarray[0]) ' cog for DTbus R/Ws; Cog 3; PASD; CmdStatus=>StatAsm @ PAR
    '  id := dbg.start(31,30,@entry) ' Include for PASD debugger (NOTE:  PASD needs a 'xxx.bin' file)
            
    {{  term.start(RX1, TX1, %0000, 115_200)                  ' init FDS
    
      term.str(string(CLS, "QuickStart LCD test, 15 Aug.2011"))     
      waitcnt((MS_001 * 1000 +cnt))                                  }}
      initLCD
      dira[LED7..LED0]~~            ' LEDs are outputs from Prop
    '  DIRA[E_LCD..PAD0]~~           ' make P0..P11 outputs on Prop   (this just a TEMP use)
      cntDn := 0
                                                           
      repeat
        if cntDn == 0               ' check if value reached zero
          cntDn := $0000_0FFF       '   if so, set to FFFh
        outa[LED7..LED0] := cntDn   ' output cntDn value to LEDs
        OUTA[PAD7..PAD0] := $0000_00FF & cntDn  ' output also to LCD's 8 lines
        chr := $00FF & cntDn
        wr_LCD
    {{    term.tx(HOME)
        term.hex(cntDn, 4)
        term.tx(CR)                 }}   
        cntDn := cntDn - 1          ' decrement value
        waitcnt((MS_001 * 1000) +cnt)        ' pause to display for human eyes; ~45 ms loop time by scope
    
    '+-------------------------------------------------------------------------------------+    
    PUB optional_configure_viewport                                 ' FROM CONTROL1                                                               
      vp.config(string("var:io(bits=[all[0..29],30tx,31rx])"))
      vp.config(string("var:io,cntDn,chr")) ' show these VARs
      vp.config(string("lsa:view=io,timescale=10us,trigger=io[16]r")) ' trig on A23 rising
      vp.config(string("edit:chr(default=5,mode=text),cntDn(mode=text)"))
      vp.config(string("start:lsa"))                                            
    '+-------------------------------------------------------------------------------------+
    
    PUB initLCD
    {{  term.tx(CR)                  }}
      DIRA[E_LCD..PAD0]~~           ' make P0..P11 outputs on Prop
      OUTA[E_LCD..reset_LCD] := $1<<8     ' set E_LCD..reset_LCD (LCD control lines) LO
      waitcnt(MS_001*2100+ cnt)     ' delay about 20 ms
    ' OUTA[reset_LCD]~           ' release reset line
    '  waitcnt(MS_001*10 + cnt)  
      chr := $1C                    ' turn on LCD driver power
      wr_LCD                        ' send command
      chr := $14                    ' turn on character display
      wr_LCD
      chr := $28                    ' set for '2 by 12 char. lines'
      wr_LCD
      chr := $4F                    ' set at darkest contrast
      wr_LCD
      chr := $E0                    ' set data address to first location
      wr_LCD
      OUTA[RS_LCD]~~                ' set RS line Hi for Data transfer
      waitcnt(MS_001*100 + cnt)  
    {{  term.str(string(CLS, "initLCD done"))
      term.tx(CR)                                   }}
    
    PUB wr_LCD                      ' enter with RS Hi for Data, LO for Commands
      OUTA[E_LCD]~~                 ' E line Hi to load value
    '  waitcnt(MS_001 + cnt)
      OUTA[PAD7..PAD0] := chr       ' byte to LCD for Data/Command
    '  waitcnt(MS_001 + cnt)
      OUTA[E_LCD]~                  ' drop E line to latch the value
    {{    term.tx(HOME)                                       ' TEMP USE, this, next5 lines
        term.str(string("wr_LCD = "))
        term.hex(chr, 2)
        term.tx(CR)                          }}
      waitcnt(MS_001 * 10+ cnt)        ' wait for about 1 millisecond   ' 10 ms enough ???
    
    dat
    

    Jim
  • HShankoHShanko Posts: 402
    edited 2011-08-16 13:07
    @ StefanL38

    'OK' is meant that the LSA displays waveforms as expected. 'Not working' means it doesn't configure and thus no LSA display.

    @ all, Today I installed ViewPort vdr. 4.6.0. Bummer. I now get a "Problem with conduit version on COM3" error. I tried to verify there are no other conduits in the \lib folder. It is dated 7.16.2011; I suppose that is only the install date, as I downloaded v 4.6.0 several days ago.

    Something strange about the Open in VP is quite different than in the Parallax IDE. I had a problem with an old .spin file on the Desktop that could only be seen by VP, yet the IDE could see the newest which was in the Tutorials folder. VP wouldn't let me look into the Tutorials folder!!!

    Any clue as to why the 'conduit' problem'?
  • HShankoHShanko Posts: 402
    edited 2011-08-17 11:14
    @ anyone

    Yesterday was mostly used up by non-Prop activities. Today I took a closer look and on searching found about a half-dozen Conduit files in various places, one on the desktop. Deleted that one and it finally runs. Not only on my 2-Prop board but also the QuickStart board. I don't know where all those Conduit files came from, but I've gone through a large number of VP versions since Hanno was beta testing VP. I'll delete the others later on, but seeing the ViewPort application run, I'm happy.

    For some reason installing ver 4.6.0 showed up this problem. To my knowledge I'd not moved any Conduit file around except to place one in the VP 'lib' folder.
Sign In or Register to comment.