Parallax P2-EVAL (P2ES chip) pcb demo code

1235»

Comments

  • pilot0315 wrote: »
    Hey thanks a lot for the help. I will look for the P2PASM.
    Martin

    I'm pretty sure the ROM could be compiled by any of the assemblers available for P2 -- PNut, fastspin, or p2asm. With PNut you might need the most recent version (32j).
  • ke4pjw wrote: »
    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

    Yes, for P1 you do not need a clkset. For P2 we do, because (at the moment) there's no implicit clkset() in the startup routine. clkset() is a lot heavier weight in P2 (it requires waiting for a pretty significant period of time (10 milliseconds or so). So I didn't want to make this hidden from the user. It's still only needs to be done once, in the top spin file.

    We're also still figuring out what the best clock settings are for P2, so again, it's probably nice not to hide that detail from users.

    All of the tools are still under active development. The P2 is not (at this early stage) a beginner friendly platform. As the tools mature that will change!
  • To ersmith,

    Thanks, I got it going. Now going to play. If I run into any other snags I will let you know.
    Appreciate it.


  • to evanh
    Thanks
  • samuellsamuell Posts: 531
    edited 2019-01-16 - 13:48:38
    Or in TAQOZ try this for effect:
    56 8 ADO I PIN 4 HZ 20 ms LOOP
    
    I haven't tried it but not only should the leds blink but with the 20ms delay there should be a rippling effect as well.
    The 20ms is actually closer to 80ms due to timing difference between RCFAST and 80MHz FPGA (same with the 20 ms)

    BTW - I haven't got a P2-ES board but I could hook up some leds on my P2D2 and video it.

    Breakdown of that code:
    56 - push 56 onto the stack 
    8 - push 8 onto the stack 
    ADO - take two values from the stack ( start=56 count=8 ) and set loop for effectively 8 times starting with I = 56
    I - leave current index value on stack
    PIN - use value from stack to select a pin
    4
    ms - delay for milliseconds specified
    LOOP - increment index until start+count is reached else continue to loop back to code following ADO  
    ( implicit EXIT or return )
    
    Hi Peter,

    I had to adapt the code, since TAQOZ was freezing. Since pins 62 and 63 are problematic in that respect, I had to change the code to:
    56 6 ADO I PIN 4 HZ 20 ms LOOP
    
    Anyway, it is a nice effect. Is there any TAQOZ way to exercise the cogs?

    Kind regards, Samuel Lourenço
  • Hi,

    I've loaded up an SD card with the .BIX file provided in the start of this thread, but I can't get the program to boot. I can see the contents of the SD card under TAQOZ, using the "DIR" command. I'm using the original dipswitch configuration (BOD=1, FLASH=0, P59UP=0, P59DN=0).

    Kind regards, Samuel Lourenço
  • Peter JakackiPeter Jakacki Posts: 9,101
    edited 2019-01-16 - 22:24:59
    This is the TAQOZ1V1 SD BOOT image you should use for the P2-ES board.

    The Introduction to TAQOZ has links for these at the start of the document as well as the P2 LINKs sticky thread.


    BTW - if you want to load up another cog with TAQOZ use NEWCOG and then you can get it to run like this (ROM version):
    (This is my terminal copy&paste, as is including typos etc, and I use ^X to reexecute the previous command on some lines)
    TAQOZ# 1 NEWCOG  ok
    TAQOZ#   ok
    TAQOZ# long counter  ok
    TAQOZ# : COUNT_TASK BEGIN counter ++ AGAIN ;  ok
    TAQOZ# ' COUNT_TASK 1 RUN ???   ok
    TAQOZ# ' COUNT_TASK 1 TASK W!  ok
    TAQOZ# counter @ . -38590398 ok
    TAQOZ# -38516446 ok
    TAQOZ# -38467762 ok
    TAQOZ# -38415683 ok
    TAQOZ# -38277814 ok
    TAQOZ# 0 counter !  ok
    TAQOZ# counter @ . 179222 ok
    TAQOZ# 239858 ok
    TAQOZ# 315675 ok
    
    So after loading cog 1 with a copy of TAQOZ it sits in an IDLE loop looking for a "job" and when the vector is non-zero it will load this and start executing from there. Each cog has an entry in the task table with the job vector being the first 16-bits. Once a job is started and unless it exits back to IDLE it won't execute other jobs. However you can always override the cog with NEWCOG at anytime.
  • samuellsamuell Posts: 531
    edited 2019-01-17 - 12:57:39
    Thanks Peter,

    I've copied the file into the SD card, but still doesn't load. The TAQOZ version is the same. Am I missing a step?

    Update: Confirmed that loading only from the SD card fails. P59DN switch was set to 1. No TAQOZ v1.1 in sight. The card may have an issue with the formatting, or something.

    Kind regards, Samuel Lourenço
  • Cluso99 or anyone.

    I downloaded the "_BOOT_P2.BIX" for the sd card. How do I access it. Would someone give me some example code please.

    Thanks
  • samuellsamuell Posts: 531
    edited 2019-01-21 - 02:16:56
    samuell wrote: »
    Thanks Peter,

    I've copied the file into the SD card, but still doesn't load. The TAQOZ version is the same. Am I missing a step?

    Update: Confirmed that loading only from the SD card fails. P59DN switch was set to 1. No TAQOZ v1.1 in sight. The card may have an issue with the formatting, or something.

    Kind regards, Samuel Lourenço
    Ok, finally solved. Had to reformat the SD card using the "SD Card Formatter" application for Windows, then copied "_BOOT_P2.BIX" again and then, under Linux, deleted the "System Volume Information" via terminal. This way I made sude I only had that file to boot.
    pilot0315 wrote: »
    Cluso99 or anyone.

    I downloaded the "_BOOT_P2.BIX" for the sd card. How do I access it. Would someone give me some example code please.

    Thanks
    Just copy the file to an empty SD Card, and reset with the switches off (you can leave BOD on). Make sure your card is well formatted. If you need to reformat, don't use the OS format application: use an application specific for SD cards and compliant with the specs.

    Kind regards, Samuel Lourenço
  • I think it was deleted long filenames caused a boot problem. Or might have been any long filenames first caused it. I never tried again so have forgotten the detail.

  • I reformatted the sd card and copied it over. What switches are you talking about?? what is BOD? I am assuming that I can call this as a subroutine so I can print to the Serial Terminal??
    Thanks
  • The P2 Eval board has 4 DIP switches, BOD, flash, P59up, P59down
  • pilot0315 wrote: »
    I reformatted the sd card and copied it over. What switches are you talking about?? what is BOD? I am assuming that I can call this as a subroutine so I can print to the Serial Terminal??
    Thanks

    "BOD" Brown Out Detection
  • PublisonPublison Posts: 11,366
    edited 2019-01-21 - 18:09:36
    I reformatted the sd card and copied it over. What switches are you talking about?? what is BOD? I am assuming that I can call this as a subroutine so I can print to the Serial Terminal??
    Thanks

    Referring to this document:
    https://docs.google.com/document/d/1gIKAfx5slcwjrAvHnbn5VNReY2SbQxtYkgO8cIzjyyY/edit#heading=h.6frgvwkw4djo

    Page 3 picture shows the Mode Selection Switch Bank.

    Page 9 shows the Boot Mode Selections.

  • samuellsamuell Posts: 531
    edited 2019-01-22 - 01:59:24
    pilot0315 wrote: »
    I reformatted the sd card and copied it over. What switches are you talking about?? what is BOD? I am assuming that I can call this as a subroutine so I can print to the Serial Terminal??
    Thanks
    Are you using the P2-ES board? Or the FPGA? On the ES board, you'll have four DIP switches: The first one says BOD (Brown Out Detection). The first you can leave on, the others should be in the off position.

    If you load the new TAQOZ from the SD card, it should appear right at the start, after a reset, without having to do the "> ESC" combination.

    Kind regards, Samuel Lourenço
  • Samuel,
    I am using the ES board. Switches are BOD on and the others are off.
  • So if I can get this to boot. What am I going to see??
  • Samuel,
    I am using the ES board. Switches are BOD on and the others are off.
  • PublisonPublison Posts: 11,366
    edited 2019-01-26 - 23:55:09
    pilot0315 wrote: »
    Samuel,
    I am using the ES board. Switches are BOD on and the others are off.

    Give this a try. Fire up PST, (Parallax Serial Terminal). Power up the ES Board with the SD with TAQOZ loaded. Connect to to COM port in PST. (Make sure Enable PST if it is blinking). Wait one minute, then hit the reset button on the ES board. That should bring up the TAQOS prompt.

    Sometimes I have to toggle DTR in PST,(on then off), then a reset to get the SD to load. May just be my board.
  • Publison wrote: »
    pilot0315 wrote: »
    Samuel,
    I am using the ES board. Switches are BOD on and the others are off.

    Give this a try. Fire up PST, (Parallax Serial Terminal). Power up the ES Board with the SD with TAQOZ loaded. Connect to to COM port in PST. (Make sure Enable PST if it is blinking). Wait one minute, then hit the reset button on the ES board. That should bring up the TAQOS prompt.

    Sometimes I have to toggle DTR in PST,(on then off), then a reset to get the SD to load. May just be my board.
    Strangely I need to do this when using TeraTerm, with the v2.0 image loaded. It used to work right of the bat.

    Kind regards, Samuel Lourenço
  • Pink Noise generation at 2MSPS, using Stenzel's method, 1/f response from about 30Hz upto nearly 1MHz.

    The xoro32 generator provides the random bits, the output goes to a DAC pin in 16 bit dither mode.

    Stenzel's really cunning pink noise method can be studied here: stenzel.waldorfmusic.de/post/pink/ and here: https://github.com/Stenzel/newshadeofpink
    {{
    ////////////////////////////////////////////////////////////////////////////////////////////
    //                  stenzel_pink_noise.spin2
    // Pink noise generation using the "new shade of pink" algorithm by Stenzel:
    //    http://stenzel.waldorfmusic.de/post/pink/
    //    https://github.com/Stenzel/newshadeofpink
    
    
    // Author: Mark Tillotson
    // Updated: 2019-01-28
    // Designed For: P2X8C4M64PES
    // Version: 1.0
    
    // Provides Start
    //   Functions:
    
    //   PUB Start (dest, scale)
    //        dest points to a long to which pink noise samples are written every 512 clock cycles
    //        scale is a non-negative left shift count used to scale up the results from their natural range
    }}
    
    CON
        OSCMODE = $010c3f04
        FREQ = 160_000_000
        BAUD = 2*115200
    
        PERIOD = $200  ' can be interrogated by client of this object, clocks per iteration
        POWER = 16
    
        DACpin = 48
        dither_dac = %0000_0000_000_10100_00000000_01_00010_0
        
    OBJ
        ser: "SmartSerial.spin2"
    
    PUB Demo
        clkset (OSCMODE, FREQ)
        ser.start (63, 62, 0, BAUD)
    
        ser.str (string ("Stanzel pink noise generator"))
        ser.tx (13)
        ser.tx (10)
        pausems(1000)
    
        table_addr := @firtable
        cognew (@asm_entry)
    
    DAT
    
    
    
    { --------------------- main setup and loop with waitct1 --------------------- }
    
      		ORG     0
    		
    asm_entry       mov	PTRB, table_addr  ' copy tables to LUTram
    		mov	t, #0
    
    		REP	@.done, #128
    		rdlong	accum, PTRB++
    		WRLUT	accum, t
    		add	t, #1
    .done
    		wrpin	##dither_dac, #DACpin
    
    		getct	time
    		mov	resul, #0
    .loop
    		addct1	time, #80
    		WAITCT1
    		wypin	resul, #DACpin
                    call    #stenzel
    		sar	resul, #4
    		add	resul, dac_offset
    		jmp	#.loop
    
    stenzel
    		' get bit mask from counter's lowest 1 and bit reversing
    		'add	counter, #1
    		'and	counter, mask
    		incmod  counter, mask
    		mov	bitmask, counter
    		neg	t, counter
    		and	bitmask, t    ' find lowest set bit in counter
    		rev	bitmask
    		shr	bitmask, #32-POWER  ' reverse so highest bit changes most rapidly
    
    		getrnd	rand_sample
    		testb	rand_sample, #12  wc
    		
    		andn	dec, bitmask
    		mov	t, inc
    		and	t, bitmask
    		or	dec, t
    	if_c	xor	inc, bitmask
    		add	accum, inc
    		sub	accum, dec
    
    		mov	resul, accum
    
    		mov	t, rand_sample  ' lookup lower bits 5:0
    		and	t, #$3F
    		rdlut	t, t
    		add	resul, t
    
    		mov	t, rand_sample  ' lookup next bits 11:6
    		shr	t, #6
    		and	t, #$3F
    		add	t, #$40
    		rdlut	t, t
    		add	resul, t
    
    stenzel_ret	ret
    
    
    table_addr	long	@firtable
    scale_shift 	long	0
    inc		long	$CCCC
    dec		long	$CCCC
    accum		long	0
    dac_offset	long	$8000
    counter		long	0
    mask		long    $FFFF
    
    bitmask		res	1
    t		res	1
    time            res     1
    resul		res	1
    rand_sample	res	1
    
    		FIT	$1F0
    
    
    firtable        long    -45437
                    long    32588
                    long    -34782
                    long    43243
                    long    -45292
                    long    32733
                    long    -34638
                    long    43387
                    long    -43768
                    long    34257
                    long    -33113
                    long    44912
                    long    -43623
                    long    34402
                    long    -32968
                    long    45057
                    long    -45537
                    long    32488
                    long    -34882
                    long    43143
                    long    -45392
                    long    32633
                    long    -34737
                    long    43288
                    long    -43867
                    long    34158
                    long    -33212
                    long    44813
                    long    -43723
                    long    34302
                    long    -33068
                    long    44957
                    long    -44957
                    long    33068
                    long    -34302
                    long    43723
                    long    -44813
                    long    33212
                    long    -34158
                    long    43867
                    long    -43288
                    long    34737
                    long    -32633
                    long    45392
                    long    -43143
                    long    34882
                    long    -32488
                    long    45537
                    long    -45057
                    long    32968
                    long    -34402
                    long    43623
                    long    -44912
                    long    33113
                    long    -34257
                    long    43768
                    long    -43387
                    long    34638
                    long    -32733
                    long    45292
                    long    -43243
                    long    34782
                    long    -32588
                    long    45437
    highpart
                    long    -231
                    long    -115
                    long    66
                    long    182
                    long    -333
                    long    -217
                    long    -36
                    long    80
                    long    -180
                    long    -64
                    long    117
                    long    233
                    long    -282
                    long    -166
                    long    14
                    long    131
                    long    -263
                    long    -147
                    long    34
                    long    150
                    long    -365
                    long    -249
                    long    -68
                    long    48
                    long    -212
                    long    -96
                    long    85
                    long    201
                    long    -314
                    long    -198
                    long    -17
                    long    99
                    long    -99
                    long    17
                    long    198
                    long    314
                    long    -201
                    long    -85
                    long    96
                    long    212
                    long    -48
                    long    68
                    long    249
                    long    365
                    long    -150
                    long    -34
                    long    147
                    long    263
                    long    -131
                    long    -14
                    long    166
                    long    282
                    long    -233
                    long    -117
                    long    64
                    long    180
                    long    -80
                    long    36
                    long    217
                    long    333
                    long    -182
                    long    -66
                    long    115
                    long    231
    
    
    {{
    ////////////////////////////////////////////////////////////////////////////////////////////
    //                                TERMS OF USE: MIT License
    ////////////////////////////////////////////////////////////////////////////////////////////
    // Permission is hereby granted, free of charge, to any person obtaining a copy of this 
    // software and associated documentation files (the "Software"), to deal in the Software 
    // without restriction, including without limitation the rights to use, copy, modify, merge,
    // publish, distribute, sublicense, and/or sell copies of the Software, and to permit 
    // persons to whom the Software is furnished to do so, subject to the following conditions:
    //
    // The above copyright notice and this permission notice shall be included in all copies or
    // substantial portions of the Software.
    //
    // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
    // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
    // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
    // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
    // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
    // DEALINGS IN THE SOFTWARE.
    ////////////////////////////////////////////////////////////////////////////////////////////
    }}
    

    The 1/f nature of the output as displayed on spectrum analyzer on log-log scale (Bode plot):
    SSA_190129072930.png
  • Mark_T how did you imbed the above image into the text area??
    Also I have not been able to access _BOOT_P2.BIX via the sd card. Can someone walk me through it. I am assuming that I will be able to access the PST terminal using the P2asm code. Would someone give me a simple example of doing that. Something like just printing a variable. If you look at my simple tutorial using pasm from spin I would like to start simple.
    Thanks.

    http://forums.parallax.com/discussion/169380/pasm-tutorial#latest
  • msrobotsmsrobots Posts: 3,141
    edited 2019-01-30 - 10:09:08
    I am using Spin2Gui from @ersmith and that uses a terminal provided by the loader, I guess.

    But it is a all in one solution, you can write PASM2, SPIN2, BASIC and some C code with the same IDE. All gets compiled down to PASM2 (and you can look at the result) and can be started using the build in terminal. No need for PST.

    As far as I understand _BOOT_P2.BIX is just any loadable binary named like that and saved to SD. It should then start. Try the newer rom version of TAQOZ @Peter Jakacki has in his drop-box. If you save the file as _BOOT_P2.BIX in the root of the SD it should start without changing any jumpers on the EVVAL board.

    Then create your own binary using PNUT/spin2gui/spinedit and do the same...

    Enjoy!

    Mike
  • pilot0315 wrote: »
    Mark_T how did you imbed the above image into the text area??

    With the image icon as normal. I'm hosting the image, its not in the forum.
  • Mark_T. found it thanks
Sign In or Register to comment.