Parallax P2-EVAL (P2ES chip) pcb demo code

124

Comments

  • Ha, finally a shop and desk somehow reminding me of my 'office'.

    Enjoy!

    Mike
    I am just another Code Monkey.
    A determined coder can write COBOL programs in any language. -- Author unknown.
    Press any key to continue, any other key to quit

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this post are to be interpreted as described in RFC 2119.
  • @dgately, try DIV = 2 and MUL = 25 (still gives 250 MHz dot clock)

  • jmgjmg Posts: 12,884
    Cluso99 wrote: »
    Seems like touching the P2 chip has nothing to do with cooling the chip. Perhaps it is either capacitance or grounding related.

    Just where you touch matters, as does the pressure, so I changed to a 3.5mm drill (flat end) and that shows a sensitive area in the die, which will be the VCO/PFD spot.

  • Where is this area?
    Do not taunt Happy Fun Ball! @opengeekorg ---> Be Excellent To One Another SKYPE = acuity_doug
    Parallax colors simplified: https://forums.parallax.com/discussion/123709/commented-graphics-demo-spin<br>
  • jmgjmg Posts: 12,884
    potatohead wrote: »
    Where is this area?

    Nearest the XTAL corner, just below the AX in Parallax.
  • ozpropdev's mistake on oscillator made me check my own code...
    Seems I had _XOSC set wrong in the VGA demo's I posted.
    I'm surprised it works with _XOSC=%01, but it did...
    Changed to _XOSC=%10 now...
    Prop Info and Apps: http://www.rayslogic.com/
  • Tubular wrote: »
    @dgately, try DIV = 2 and MUL = 25 (still gives 250 MHz dot clock)
    And, Rayman's: change: _XOSC=%01 to _XOSC=%10...

    Yes, this stopped the jitter (about 10 minutes and still rock-steady)@!

    dgately
    Livermore, CA (50 miles SE of San Francisco)
  • jmgjmg Posts: 12,884
    edited 2018-12-28 - 19:19:49
    Rayman wrote: »
    ozpropdev's mistake on oscillator made me check my own code...
    Seems I had _XOSC set wrong in the VGA demo's I posted.
    I'm surprised it works with _XOSC=%01, but it did...
    Changed to _XOSC=%10 now...

    Yes, all 3 cap choices seem to oscillate fine.
    The 0pF one is not really Zero, as there is still PAD IO capacitance, and package and PCB capacitance.

    On my tests I get +144 ppm , -6.7 ppm, -53 ppm for the 3 settings, so the best Xtal match is the %10 setting.
    The %01 does bump the crystal quite a long way high.

    I've not tried change of the C's while running yet, but given the Xtal source does not like being enabled too early, it seems P2 can be disturbed by noise.
    The Xtal C switches are unlikely to be 'soft' & the worse case would be connecting a C with the opposite voltage to the XI,XO at that instant.
    I'd guess it's probably unsafe to change Xtal C's on the fly, but my forth is not good enough to code a test.

  • Quick change to "all_cogs_blink.spin2" gets the leds flashing...
    Prop Info and Apps: http://www.rayslogic.com/
  • Rayman wrote: »
    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...

    Thank you for posting this Rayman. Should the video signals be...

    P1 B
    P2 G
    P3 R

    ??

    Should the birds be Yellow or Blue?

    Thanks in advance.
    Feel the need for speed between your PC's com port and Prop?
    Try the FTDI 245 and the FullDuplexParallel Object.

    Check out my spin driver for the Parallax "96 x 64 Color OLED Display Module" Product ID: 28087
  • Today I went looking for the autobaud setting when the Monitor/Debugger is called by the ROM using "> " + Ctl-D + <cr>. The same applies to calling TAQOZ.

    When the Monitor or TAQOZ is called via the ROM, the autobaud setup value (and set to 8 bits) is in the COG at $169 (the variable a0).

    I couldn't do what I wanted, but thought I'd post it here in case anyone wanted to know the value the smartpins are set to.
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • RaymanRayman Posts: 9,126
    edited 2019-01-10 - 11:18:55
    Just open the bmp file on computer to see what birds should look like
    I think they are yellow
    Prop Info and Apps: http://www.rayslogic.com/
  • Yes yellow, "Sun Conure"
  • For Cluso

    I was wondering if you had a serial terminal routine for the p2 that is a stand alone. I am trying to tease out the serial portion only.
    Could you help.
    Cluso's P2ES-EVAL-Demo-002 for P2-ES v32i Silicon
    Thanks
    I will post this in the forums.

    Martin
  • Not currently at my pc.
    Do you just want the serial with Tx and Rx or do you want the extras such as hex, string, etc?
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • evanhevanh Posts: 6,078
    edited 2019-01-13 - 20:55:26
    Here's mine:
    '*******************************************************************************
    ' Subroutines
    '*******************************************************************************
    ORGH
    ALIGNL
    '===============================================
    diaginit
    '  Only called once at beginning
    
    '-------- Copy lut code into position --------
    		setq2	#(LUT_end - LUT_code - 1) 'copy length, in longwords
    		rdlong	0, ##@LUT_code            'the "0" is lutRAM zero, or $200 in memory map
    
    '----- Configure diag comport to use smartpins instead of bit-bashing -----
    		wrpin   #%00_11111_0, #rx_pin 'Asynchronous serial receive
    		wxpin   asynconfig, #rx_pin   'set baurdrate and framing
    		dirh    #rx_pin
    		wrpin   #%01_11110_0, #tx_pin 'Asynchronous serial transmit mode
    		wxpin   asynconfig, #tx_pin   'set X with baudrate and framing
    		dirh    #tx_pin               'release Z from zero
    _ret_		wypin   #0, #tx_pin           'trigger first tx ready state (not needed if dual checked)
    		                              'single check is buffer full only, dual checking adds in tx flag
    
    
    
    ORG   $200                                    'longword addressing
    '*******************************************************************************
    '  LUT Code  (Has to be copied from hubram to lutram)
    '*******************************************************************************
    LUT_code
    
    
    '===============================================
    getch
    		testp   #rx_pin         wz
    if_nz		jmp     #getch                'wait while Smartpin is idle
    		rdpin   char, #rx_pin
    		shr     char, #32-8           'shift the data to bottom of register
    		ret                     wcz   'restore C/Z flags of calling routine
    
    
    
    '===============================================
    putch
    '		rqpin   temp1, #tx_pin  wc    'transmiting?  (read Z to see if actively shifting out)
    		testp   #tx_pin         wz    'buffer free?  (IN state shows Y buffer full status)
    'if_nz_and_c	jmp     #putch                'wait while Smartpin is both full (nz) and transmitting (c)
    if_nz		jmp     #putch                'wait while Smartpin is full (nz)
    		wypin   char, #tx_pin         'write new byte to Y buffer
    		ret                     wcz   'restore C/Z flags of calling routine
    
    
    
    '===============================================
    'CR/LF emit
    putnl
    		mov     char, #13
    		call    #putch
    		mov     char, #10
    		jmp     #putch
    
    
    
    '===============================================
    'Space emit
    putsp
    		mov     char, #" "
    		call    #putch
    		mov     char, #" "
    		call    #putch
    		mov     char, #" "
    		jmp     #putch
    
    
    
    '===============================================
    'String emit
    puts
    		rdbyte  char, pa        wz
    if_z		ret                     wcz   'null termination, C/Z preserved
    		call    #putch                'emit character
    		ijnz    pa, #puts             'increment pointer (assumes non-zero address)
    
    
    
    '===============================================
    'Integer (long) to ascii binary and emit
    itobl
    		rev     pa                    'least significant first
    itob
    		mov     bcdi, #32
    .emit
    		rol     pa, #1          wc
    if_nc		mov     char, #"0"
    if_c		mov     char, #"1"
    		call    #putch
    		djnz    bcdi, #.emit
    		ret                     wcz   'restore C/Z flags of calling routine
    
    
    
    '===============================================
    'Integer (long) to ascii hexidecimal and emit
    itohl
    		rev     pa                    'least significant first
    itoh
    		mov     bcdi, #7              'most significant nibble first (zero extended)
    .emit
    		altgn   bcdi, #pa             '(instruction prefix)
    		getnib  char                  'retrieve next hex digit from pa register:  char = pa[bcdi]
    		cmp     char, #10       wcz   'test if below 10, C = borrow of (D - S)
    if_c		add     char, #"0"            'ASCII encode 0-9
    if_nc		add     char, #"a"-10         'ASCII encode a-f
    		call    #putch
    		djnf    bcdi, #.emit
    		ret                     wcz   'restore C/Z flags of calling routine
    
    
    
    '===============================================
    'Integer (long) to ascii decimal and emit
    '  Note:  Uses the CORDIC.  This means that any already running operations will be corrupted
    '  Also requires bcdlen set for the number of digits to be emitted
    
    itod
    'convert 32-bit integer to BCD
    		qdiv    pa, #10               'had to cheat.  It's hard without divide and modulo
    		mov     bcdstr, #0            'clear bcdstr to all zeros
    		mov     bcdstr+1, #0
    		mov     bcdi, #0              'reset digit index
    		fle     bcdlen, #15           'hard limit of 15 digits for string length
    
    .makebcd
    		getqx   pa              wz    'collect result for recursion
    		getqy   char                  'collect decimal digit
    
    if_nz		qdiv    pa, #10               'recurse for next digit
    
    		altsn   bcdi, #bcdstr         '(instruction prefix)
    		setnib  0-0, char, #0-0                  'file the decimal digit as BCD:  bcdstr[bcdi] = chr
    if_nz		ijnz    bcdi, #.makebcd
    
    
    'Emit BCD as a string to comport
    		fge     bcdi, bcdlen          'set minimum string length
    .leadin
    		altgn   bcdi, #bcdstr         '(instruction prefix)
    		getnib  char                  'retrieve next digit from BCD:  char = bcdstr[bcdi]
    		cmp     char, #0        wz
    if_z		mov     char, #" "            'replace with leading spaces
    if_z		call    #putch                'Relies on #putch preserving C/Z flags
    if_z		djnz    bcdi, #.leadin
    
    .emit
    		altgn   bcdi, #bcdstr         '(instruction prefix)
    		getnib  char                  'retrieve next digit from BCD:  char = bcdstr[bcdi]
    		add     char, #"0"            'encode ASCII
    		call    #putch
    		djnf    bcdi, #.emit
    		ret                     wcz   'restore C/Z flags of calling routine
    
    
    LUT_end
    FIT   $400
    
    

    EDIT, 14-1-2019: Include lutram copying in the init function
    Money is a placeholder for cooperation
  • It needs some cogRAM variables and #constants defined as well. They're pretty self explanatory I think. Eg:
    CON
    	_XTALFREQ     = 20_000_000                              ' crystal frequency
    	_XDIV         = 2                                       ' crystal divider to give 10MHz
    	_XMUL         = 25                                      ' 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
    	_SETFREQ      = 1<<24 + (_XDIV-1)<<18 + (_XMUL-1)<<8 + _XPPPP<<4 + _XOSC<<2
    	_ENAFREQ      = _SETFREQ + _XSEL                        ' %0000_000e_dddddd_mmmmmmmmmm_pppp_cc_ss  ' enable oscillator
    
    
    'Serial functions for data logging
    	rx_pin        = 63
    	tx_pin        = 62
    	baud_rate     = 115_200
    	clock_freq    = _XTALFREQ / _XDIV * _XMUL / _XDIVP
    
    

    You can see I pillaged Cluso's sysclock setting constants. Those are rather nice.
    Money is a placeholder for cooperation
  • To Cluso,
    I want to be able to tx numbers and characters and r1x strings etc. I am going to port over my P1 asm tutorial and work with my gps as a start with P2 asm. I would also ask for comments so I can understand what is happening. I am presently attempting to port over SimpleSerial to P1 so I can understand what is going on.

    Thanks

    Martin
  • I want to use it as a subroutine.
  • To Cluso,
    Re: Not currently at my pc.
    Do you just want the serial with Tx and Rx or do you want the extras such as hex, string, etc?


    Yes is possible.

    Thanks
  • Here are two different serial routines for P2. They're written in Spin rather than pasm, but porting to pasm should be straightforward. SimpleSerial works by bit-banging; SmartSerial uses the smart pins.

    (The file extension is .spin for SimpleSerial because it can work on P1 as well. SmartSerial, because it uses the smart pins, can only work on P2.)
  • I will look at them, thanks. I assume I can run these in spin2gui or one of the other gui's that I have seen in the forums.
    Btw in Cluso's P2ES-EVAL-Demo-002 for P2-ES v32i Silicon I am looking at stuff like this:
    _rlongcoghub =$fcfe4.

    I have been scanning the P2 documentation searching for these $fcf3e4. They do not come up. Some clarification please.
    Thanks
  • Btw I have been attempting to port simpleserial to p1 pasm not having much luck.
    Thanks
  • I just looked at the spin2 version. I have this and attempted to do a simple print but had issues using spin2gui. Can you give me an example program please.
    Thanks
  • SmartSerial.spin2 basically works just like FullDuplexSerial. Here's a sample program:
    ' SmartSerial hello world program
    ' just repeats "hello, world!" over and over
    
    CON
      oscmode = $010c3f04
      freq = 160_000_000
      baud = 2_000_000 ' default baud rate for loadp2 / spin2gui
    
    OBJ
      ser: "SmartSerial.spin2"
    
    PUB demo
      clkset(oscmode, freq)
      ser.start(63, 62, 0, baud) ' P2 serial default pins
      repeat
         ser.str(string("Hello, world!", 13, 10))
    


  • I will try this. For some reason I get errors regarding finding the smartserial obj. It is in the library for spin2gui but does not see it.
    I will let you know.

    Thanks
    Martin
  • Looking at your example I think I see my error.
  • pilot0315 wrote: »
    I will look at them, thanks. I assume I can run these in spin2gui or one of the other gui's that I have seen in the forums.
    Btw in Cluso's P2ES-EVAL-Demo-002 for P2-ES v32i Silicon I am looking at stuff like this:
    _rlongcoghub =$fcfe4.

    I have been scanning the P2 documentation searching for these $fcf3e4. They do not come up. Some clarification please.
    Thanks

    In my examples, I am using the ROM routines to do the serial. Those entry points are listed as ROM addresses.
    If you want to see the ROM code you will need to compile using P2PASM. Peter has a link to the listing somewhere.
    Sorry, still haven't had time to chase this up yet. Maybe mid-week.
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • Hey thanks a lot for the help. I will look for the P2PASM.
    Martin
  • Um, help me understand why you perform clkset() inside the demo object. Why? I don't recall this in spin 1. You set the clock settings in the top spin file and never had to set it again.

    Thanks,
    Terry
    Feel the need for speed between your PC's com port and Prop?
    Try the FTDI 245 and the FullDuplexParallel Object.

    Check out my spin driver for the Parallax "96 x 64 Color OLED Display Module" Product ID: 28087
Sign In or Register to comment.