Shop OBEX P1 Docs P2 Docs Learn Events
Parallax P2-EVAL (P2ES chip) pcb demo code - Page 3 — Parallax Forums

Parallax P2-EVAL (P2ES chip) pcb demo code

135

Comments

  • I am running code that I built from the GitHub repository and it was current as of at least a few days ago. I'm running on a Mac and I'm loading PASM2 code. I haven't tried any of the high-level languages yet.
  • RaymanRayman Posts: 14,646
    edited 2018-12-26 17:40
    SpinEdit seems to work with Eval board as is (uses loadp2 and fastspin as described a couple posts ago in this thread)...
    If you want to try it, it's here in first post:
    https://forums.parallax.com/discussion/169259/spinedit-editor-for-spin-spin2-and-fastbasic

    I'm told it can work on a mac with the right serial port incantation...
  • RaymanRayman Posts: 14,646
    JonnyMac wrote: »
    Since I live and work in Hollywood, I had to do this:
    ' This program creates an 8-LED Larson scanner on the P2 Eval board
    
    dat		org
    
    ls_fwd		mov	ledpin, #56		' start with p56
    		mov	cycles, #7		' light 7 going up
    .loop		drvl	ledpin			' led on
    		waitx	##20_000_000/8		' wait 1/8 second
    		drvh	ledpin			' led off
    		add	ledpin, #1		' next pin
    		djnz	cycles, #.loop		' done? 
    
    ls_rev		mov	ledpin, #63		' start with p63
    		mov	cycles, #7		' light 7 going down
    .loop		drvl	ledpin
    		waitx	##20_000_000/8
    		drvh	ledpin
    		sub	ledpin, #1
    		djnz	cycles, #.loop
    
    		jmp	#ls_fwd
    
    
    ledpin	res	1
    cycles	res	1
    

    I didn't try this until I realized it was probably a Knight Rider thing...
    Works fine for me. I'm a bit surprised you don't need any hubset instructions...
    Does P2 always boot into RC mode? Maybe it does...
    All the other programs I see start out with a hubset #0... Maybe you don't need that...
  • I wonder if the difference is whether you're running PASM2 or Spin/BASIC/C? I think Eric mentioned a while ago that the startup code for the high-level languages sets the clock appropriately for the FPGA and not for the P2-ES chip. Are all of the people who are having trouble trying to use Spin, BASIC, or C?
  • RaymanRayman Posts: 14,646
    Cluso99 wrote: »
    I thought I would start a thread just for demo code that runs on the Parallax P2-EVAL board (with the P2-ES chip)...

    Thanks Cluso, this works for me.
    It's actually kind of nice to have serial routines stashed away at top of ram...

  • @Rayman
    Thanks
    It worked. Here's what I did.
    I put fastspin.exe, loadp2exe, and larson.spin2 in my root user directory and entered the following commands.
    C:\Users\tandj>fastspin.exe -2 "larson.spin2"
    C:\Users\tandj>loadp2.exe -p COM9 "larson.binary"
    
    Since I got it to work, I tried to find out what was wrong with my initial attempts.
    First I tried deleting the quotation marks around the file names. It still worked.
    Then I replaced loadp2.exe with the version that was in the latest spin2gui. That did not work. It gave me the same problem as I had before (appeared to load correctly, but nothing ran.)
    I replaced loadp2.exe with the version you linked to, and it worked.
    Tried the fastspin from the latest spin2gui and it worked (it is actually the same version.

    So the problem seems to be the loadp2.exe that comes with the latest version of spin2gui.

    I tried replacing the loadp2.exe in the spin2gui bin folder, but that didn't work. So I compared the command string in the the command line (that did work) and the config for spin2gui that did not work and tried removing options.

    The one that worked removed the -k option. The configure command that worked is:
    cmd.exe /c start %D/bin/loadp2 -pCOM9 %B -t 
    

    So the version of loadp2.exe in the latest spin2gui does not work, while the one posted by @Rayman does work with the -k option removed from the command configs.
    I also tried a basic program and a c program, but they did not run (they worked when compiled for P1 and run on P1.)

    Thanks for your help.
    Tom

  • RaymanRayman Posts: 14,646
    edited 2018-12-26 18:39
    Glad you got it.
    I just tried a .bas file in SpinEdit…
    It doesn't work their either... Strange spin2 works and bas doesn't...
  • Rayman wrote: »
    Glad you got it.
    I just tried a .bas file in SpinEdit…
    It doesn't work their either... Strange spin2 works and bas doesn't...
    When you say Spin2 works do you mean PASM2 code or are you actually running Spin code?

  • I changed loadp2 from a 1-stage loader to a 2-stage loader a while ago. I'll have to check GitHub to see when I did that. The main reasons I wanted to use a 2-stage loader was to load at an address other than zero, and to load at the maximum speed of 1 byte per character sent.

    If you use the 1-stage version your program will have to do a hubset. If you use the 2-stage version the user program does not need to do a hubset. However, loadp2 must be told the hubset value to use with the -m option. The devault hubset value is 0xff, which is the value used to set the FPGA P2 to 80MHz. For the P2 Eval board a different hubset value is needed. I'll look at the code Cluso posted to determine what the -m value should be for various frequencies.
  • RaymanRayman Posts: 14,646
    David Betz wrote: »
    When you say Spin2 works do you mean PASM2 code or are you actually running Spin code?

    I think it can do Spin (really Spin1.5 or so), but I'm just doing PASM with it...

  • jmgjmg Posts: 15,173
    Rayman wrote: »
    Does P2 always boot into RC mode? Maybe it does...
    All the other programs I see start out with a hubset #0... Maybe you don't need that...
    Yes, reset sets to RCFAST.
    hubset #0 is optional, I think some use that if they want to SW vector to the start again, or just to be sure... (ie TAQOZ might have changed sysclk)

  • Here's a few hubset values I calculated using Cluso's forumulas:
    _SYSFREQ =  80, _XMUL = 32, _SETFREQ = 010C1F04, _ENAFREQ = 010C1F07
    _SYSFREQ = 160, _XMUL = 64, _SETFREQ = 010C3F04, _ENAFREQ = 010C3F07
    _SYSFREQ = 180, _XMUL = 72, _SETFREQ = 010C4704, _ENAFREQ = 010C4707
    
  • RaymanRayman Posts: 14,646
    I see the problem with FastSpin BASIC now...
    It adds a hubset #255 right at the start.
    This must be bad with real P2, seems to go off the rails...
  • Rayman wrote: »
    I see the problem with FastSpin BASIC now...
    It adds a hubset #255 right at the start.
    This must be bad with real P2, seems to go off the rails...

    I compiled a basic program using spin2gui and opened the resulting p2asm file. As you noted there was a hubset #255 near the start.
    I changed that to hubset #0 saved the file and changed the extension to spin2.

    Then I clicked on "compile & run" in spin2gui (with the changes to the command configs I noted in my previous post), and the program ran on the P2ES.

    I did the same thing with a c program, and it also worked.
    I'm not sure if hubset #0 is the best setting or not.

    Tom

  • FYI HUBSET #$FF was the setting needed for FPGA's for 80MHz(max speed)
  • RaymanRayman Posts: 14,646
    hubset #0 means 20 MHz internal RC oscillator.

    That can work, but you probably want to take advantage of the ~200 MHz + you can get with crystal...
  • jmgjmg Posts: 15,173
    twm47099 wrote: »
    ...
    Then I clicked on "compile & run" in spin2gui (with the changes to the command configs I noted in my previous post), and the program ran on the P2ES.

    I did the same thing with a c program, and it also worked.
    I'm not sure if hubset #0 is the best setting or not.

    Depends on your desired MHz, #0 is safe, and selects RCFAST.

    Docs have
    HUBSET ##%0000_000E_DDDD_DDMM_MMMM_MMMM_PPPP_CCSS 'set clock mode

    where
    E - Enables PLL
    DDDDDD for PFD = XI/D
    MMMMMMMMMM for VCO/M = PFD
    PPPP for SysCLK from VCO
    CC Xtal pins mode
    SS Osc Select : RCFAST : RCSLOW : XI : PLL
    Rayman wrote: »
    It adds a hubset #255 right at the start.
    This must be bad with real P2, seems to go off the rails...
    Yes, I think that was FPGA 80MHz, but in a real P2 it does SysCLK -> VCO, but also disables PLL, so yes, a bad combination....
  • twm47099twm47099 Posts: 867
    edited 2018-12-31 01:38
    This is a C program that I wrote and the resulting pasm file that I modified and then changed
    the file extension to spin2 - Then compiled & run using spin2gui.

    // testpinsc.c
    // set & reset pins use propeller.h method
    // Turn on LEDs at pins P1,3,4 for a couple of seconds, then just Pin P2.
     
    // Turn off after a few seconds
    
    main()
    {
    int y;
    DIRA = 0;
    OUTA = 0;
    DIRA = 0b11110;
    OUTA = 0b11010;
    
    for(int i=0;i<10000000;i++);
    
    OUTA = 0b0100;
    for(i=0;i<10000000;i++);
    }
    
    
    
    'testpinsc.spin2  
    
    CON                                   ' added these constants for 180MHz setting
     _SETFREQ = $010C4708   ' constants are from Dave Hein's post
     _ENAFREQ = $010C470B
    
    dat
    	org	0
    entry
    	cmp	ptra, #0 wz
     if_ne	jmp	#spininit
    	mov	ptra, ptr_stackspace_
    	hubset	#0                        ' changed to this to be able to load & run
                                                        ' added these 3 lines to set 180MHz
            hubset  ##_SETFREQ                      ' setup oscillator
            waitx   ##20_000_000/100                ' ~10ms
            hubset  ##_ENAFREQ                      ' enable oscillator
    
    	calla	#@_main
    cogexit
    	cogid	arg01
    	cogstop	arg01
    spininit
    	rdlong	objptr, ptra
    	add	ptra, #4
    	rdlong	result1, ptra
    	add	ptra, #4
    	calla	result1
    	jmp	#cogexit
    
    objptr
    	long	@objmem
    ptr_stackspace_
    	long	@stackspace
    result1
    	long	0
    COG_BSS_START
    	fit	496
    	orgh	$400
    	long	80000000
    	long	100
    hubentry
    
    _main
    	mov	dira, #0
    	mov	outa, #0
    	mov	dira, #30
    	mov	outa, #26
    	mov	_var01, #0
    ' DIRA = 0;
    ' OUTA = 0;
    ' DIRA = 0b11110;
    ' OUTA = 0b11010;
    ' 
    ' for(int i=0;i<10000000;i++);
    LR__0001
    	cmps	_var01, ##10000000 wcz
     if_b	add	_var01, #1
     if_b	jmp	#@LR__0001
    	mov	outa, #4
    ' 
    ' OUTA = 0b0100;
    ' for(i=0;i<10000000;i++);
    	mov	_var01, #0
    LR__0002
    	cmps	_var01, ##10000000 wcz
     if_b	add	_var01, #1
     if_b	jmp	#@LR__0002
    _main_ret
    	reta
    hubexit
    	jmp	#cogexit
    objmem
    	long	0[0]
    stackspace
    	long	0[1]
    	org	COG_BSS_START
    _var01
    	res	1
    arg01
    	res	1
    	fit	496
    
    
    
  • garryjgarryj Posts: 337
    edited 2018-12-27 03:59
    Dave Hein wrote: »
    Here's a few hubset values I calculated using Cluso's forumulas:
    _SYSFREQ =  80, _XMUL = 32, _SETFREQ = 010C1F04, _ENAFREQ = 010C1F07
    _SYSFREQ = 160, _XMUL = 64, _SETFREQ = 010C3F04, _ENAFREQ = 010C3F07
    _SYSFREQ = 180, _XMUL = 72, _SETFREQ = 010C4704, _ENAFREQ = 010C4707
    
    If you want to use the 20MHz crystal part on the P2-Eval board as the source signal , should the _XOSC constant be %10 instead of %01 to engage the XI/XO loading caps? If so, this would change the LS nibble to:
    _SYSFREQ =  80, _XMUL = 32, _SETFREQ = 010C1F08, _ENAFREQ = 010C1F0B
    _SYSFREQ = 160, _XMUL = 64, _SETFREQ = 010C3F08, _ENAFREQ = 010C3F0B
    _SYSFREQ = 180, _XMUL = 72, _SETFREQ = 010C4708, _ENAFREQ = 010C470B
    
  • jmgjmg Posts: 15,173
    garryj wrote: »
    If you want to use the 20MHz crystal part on the P2-Eval board as the source signal , should the _XOSC constant be %10 instead of %01 to engage the XI/XO loading caps? If so, this would change the LS nibble to:
    _SYSFREQ =  80, _XMUL = 32, _SETFREQ = 010C1F08, _ENAFREQ = 010C1F0B
    _SYSFREQ = 160, _XMUL = 64, _SETFREQ = 010C3F08, _ENAFREQ = 010C3F0B
    _SYSFREQ = 180, _XMUL = 72, _SETFREQ = 010C4708, _ENAFREQ = 010C470B
    

    Yes, see my Xtal frequency tests here
    The correct/ideal is %10, but it does seems to oscillate on both %01 and %11, with largest deviation on the 'no cap' setting.

  • Cluso99Cluso99 Posts: 18,069
    No need to calculate all these values by hand. Just use my CON formulae and let the compiler work it out for you.
    Just change _XDIV, _XMUL & _XDIVP
    CON
      _XTALFREQ     = 20_000_000                                    ' crystal frequency
      _XDIV         = 4             '\                              '\ crystal divider                      to give 5.0MHz
      _XMUL         = 72            '| 180MHz                       '| crystal / div * mul                  to give 360MHz
      _XDIVP        = 2             '/                              '/ crystal / div * mul /divp            to give 180MHz
      _XOSC         = %10                                   'OSC    ' %00=OFF, %01=OSC, %10=15pF, %11=30pF
      _XSEL         = %11                                   'XI+PLL ' %00=rcfast(20+MHz), %01=rcslow(~20KHz), %10=XI(5ms), %11=XI+PLL(10ms)
      _XPPPP        = ((_XDIVP>>1) + 15) & $F                       ' 1->15, 2->0, 4->1, 6->2...30->14
      _CLOCKFREQ    = _XTALFREQ / _XDIV * _XMUL / _XDIVP            ' internal clock frequency                
      _SETFREQ      = 1<<24 + (_XDIV-1)<<18 + (_XMUL-1)<<8 + _XPPPP<<4 + _XOSC<<2  ' %0000_000e_dddddd_mmmmmmmmmm_pppp_cc_00  ' setup  oscillator
      _ENAFREQ      = _SETFREQ + _XSEL                                             ' %0000_000e_dddddd_mmmmmmmmmm_pppp_cc_ss  ' enable oscillator
    '------------------------------------------------------------------------------------------------
    
    DAT             orgh    0
                    org     0
    '+-------[ Set Xtal ]----------------------------------------------------------+ 
    entry           hubset  #0                              ' set 20MHz+ mode
                    hubset  ##_SETFREQ                      ' setup oscillator
                    waitx   ##20_000_000/100                ' ~10ms
                    hubset  ##_ENAFREQ                      ' enable oscillator
    '+-----------------------------------------------------------------------------+
                    waitx   ##_clockfreq*5                  ' just a delay to get pc terminal running
    
    
  • RaymanRayman Posts: 14,646
    edited 2018-12-28 12:37
    Here's the V32i VG 640x480x8bpp example adapted for real P2.
    Clock set to 250 MHz.
    Looks very solid.

    I think the changes originated from ozpropdev…

    P4=vsync, P0=hsync, P1..P3 are RGB...
  • RaymanRayman Posts: 14,646
    edited 2018-12-28 12:37
    Here's the 16bpp version at 250 MHz. Also looks good.
  • jmgjmg Posts: 15,173
    Rayman wrote: »
    Here's the 16bpp version at 250 MHz. Also looks good.

    BMP seems black ?
  • RaymanRayman Posts: 14,646
    Works for me...
  • jmgjmg Posts: 15,173
    edited 2018-12-27 20:18
    Rayman wrote: »
    Works for me...

    8 bit one is fine, the 16b one is black, with a small white rectangle in centre, on Chrome....
    It has reasonable size tho, & if I save to disk and open in Paint, it displays ok in Paint.
    Some browser issue, or a not quite right bmp ?
  • I see the same thing, jmg (Win7 / Chrome), on the second bmp

    Also like you it works fine when saved to disk. However it took many seconds to download and save to disk - perhaps its a timeout related issue.

  • RaymanRayman Posts: 14,646
    Don't know... 16bpp bmp is a bit unusual though...
  • dgatelydgately Posts: 1,630
    edited 2018-12-28 01:49
    Rayman wrote: »
    Here's the 16bpp version at 250 MHz. Also looks good.
    Just a note... With: "VGA 640 x 480 x 16bpp 5:6:5 RGB ", PNut didn't like the line:
    fset      = (fpix / fclk * 2.0) * float($4000_0000)
    
    The error: "Integer not allowed in floating point expression"
    Just change that line to:
    fset      = (fpix / float(fclk) * 2.0) * float($4000_0000)
    
    The real fun was getting an image of a P2ES into a 16bpp format that was small enough to allow the program to load it :-)
    IMG_6940.jpg
    Look close and you'll notice that the image starts to jitter (after a few minutes). Touching the P2 MCU with a "deftly" placed finger makes the jitter stop for a few seconds...

    I'll check some of the suggested ideas on removing the jitter and see how that goes.


    config info:
    Win 10 Parallels-VM, running on macOS 10.14.2
    PNut v32i
    CON  'RJA:  new for real P2 - you can use different xdiv and xmul to set clock frequency:  /10*125 -> 250 MHz
      _XTALFREQ     = 20_000_000                                    ' crystal frequency
      _XDIV         = 10                                            ' crystal divider to give 1MHz
      _XMUL         = 125                                          ' crystal / div * mul
      _XDIVP        = 1                                             ' crystal / div * mul /divp to give _CLKFREQ (1,2,4..30)
      _XOSC         = %01                                  'OSC    ' %00=OFF, %01=OSC, %10=15pF, %11=30pF
      _XSEL         = %11                                   'XI+PLL ' %00=rcfast(20+MHz), %01=rcslow(~20KHz), %10=XI(5ms), %11=XI+PLL(10ms)
      _XPPPP        = ((_XDIVP>>1) + 15) & $F                       ' 1->15, 2->0, 4->1, 6->2...30->14
      _CLOCKFREQ    = _XTALFREQ / _XDIV * _XMUL / _XDIVP            ' internal clock frequency                
      _SETFREQ      = 1<<24 + (_XDIV-1)<<18 + (_XMUL-1)<<8 + _XPPPP<<4 + _XOSC<<2  ' %0000_000e_dddddd_mmmmmmmmmm_pppp_cc_00  ' setup  oscillator
      _ENAFREQ      = _SETFREQ + _XSEL    
      
      
    CON
    
      intensity = 80    '0..128
    
      fclk      = _CLOCKFREQ 'RJA:  Adjusted for real P2 '80_000_000.0
      fpix      = 25_000_000.0
      fset      = (fpix / fclk * 2.0) * float($4000_0000)
    
      vsync     =   4   'vsync pin 'RJA:  changed for real P2
    
    DAT     org
    '
    '
    ' Setup
    '
    '+-------[ Set Xtal ]----------------------------------------------------------+ 
    ' RJA:  New for real P2
                    hubset  #0                              ' set 20MHz+ mode
                    hubset  ##_SETFREQ                      ' setup oscillator
                    waitx   ##20_000_000/100                ' ~10ms
                    hubset  ##_ENAFREQ                      ' enable oscillator
    '+-----------------------------------------------------------------------------+
    

    dgately
    766 x 1021 - 396K
  • Cluso99Cluso99 Posts: 18,069
    edited 2018-12-28 02:23
    Seems like touching the P2 chip has nothing to do with cooling the chip. Perhaps it is either capacitance or grounding related.

    With more chips in the wild, we are getting a better handle on the issues :smiley:

    I still cannot believe how well the P2 is performing, and what it can do! And we are only scratching the surface so far ;)
Sign In or Register to comment.