Shop OBEX P1 Docs P2 Docs Learn Events
Prop2 FPGA files!!! - Updated 2 June 2018 - Final Version 32i - Page 41 — Parallax Forums

Prop2 FPGA files!!! - Updated 2 June 2018 - Final Version 32i

13839414344160

Comments

  • cgraceycgracey Posts: 14,155
    Cluso99 wrote: »
    cgracey wrote: »
    Hey, Guys.

    I'm still working on the USB circuit. It's taken some time figuring out what the interface needs to be, as there are events and byte transfers to report and handle. The cog software needs to have an easy time with this. So, it's been slowly congealing what needs to be done. I think when I have it all figured out, the implementation will come together really simply.

    Great news Chip.
    Sorry I haven't been much help this time around.
    Been too busy with getting P1 on chip compilation to work under FAT32 drivers and OS - buried way deep in a few bugs ;)
    Will surface shortly :)

    I actually took a break from it over the weekend, so I'm behind where I could have been.
  • Cluso99Cluso99 Posts: 18,069
    edited 2016-03-02 07:01
    cgracey wrote: »
    Cluso99 wrote: »
    cgracey wrote: »
    Hey, Guys.

    I'm still working on the USB circuit. It's taken some time figuring out what the interface needs to be, as there are events and byte transfers to report and handle. The cog software needs to have an easy time with this. So, it's been slowly congealing what needs to be done. I think when I have it all figured out, the implementation will come together really simply.

    Great news Chip.
    Sorry I haven't been much help this time around.
    Been too busy with getting P1 on chip compilation to work under FAT32 drivers and OS - buried way deep in a few bugs ;)
    Will surface shortly :)

    Sounds good.

    What about using one Prop1 to target another? That way, if the target crashes due to a bug, you don't have to start over. That's how I've envisioned the Prop2 tools, anyway.

    That is easy. All I/O goes via common hub longs (rendezvous locations in top hub ram). The cog drivers can be replaced with serial/video/keyboard or whatever without altering the OS or Compiler. Currently I am using a PCSIO driver which is loaded into a resident cog and communicates to PST running on a PC at 115,200 baud. Absolutely no reason why this cannot be another P1 !

    If the compiler crashes it reboots the P1. It is running under my OS which uses the same indirection. The compiler is a 3 stage (LEX, CODEGEN & LINK) based on Michael Park's Sphinx Compiler, and runs on FAT16/32 using a modified version of Kye's SD_FATEngine. The OS includes Dir (sorted and * substitution), Copy, Ren, Del, Type (with a hex/ascii option too), Hubdump (hex/ascii), Free/Used (SD space), Help, Reboot, Run (a binary file), Program (the EEPROM lower or upper 32KB), Diff (difference between 2 files), and File Transfers between PC and Propeller SD card, etc. It can also read/write (transfer) CPM2.2 format disk files which we can use with the heater's Z80 emulation ZiCog and my RamBlade boards which have 512KB 55ns SRAM.

    The EEPROM contains a simple and generic boot program that looks for two files on the SD card. It loads the first one found. If my OS is present then it will be loaded, if the first file is not found. There is no requirement for a PropPlug as files can be copied to the SD card on the PC.

    Just need to get USB running properly on the P1, and ready for P2 ;)
  • cgraceycgracey Posts: 14,155
    Cluso99 wrote: »
    cgracey wrote: »
    Cluso99 wrote: »
    cgracey wrote: »
    Hey, Guys.

    I'm still working on the USB circuit. It's taken some time figuring out what the interface needs to be, as there are events and byte transfers to report and handle. The cog software needs to have an easy time with this. So, it's been slowly congealing what needs to be done. I think when I have it all figured out, the implementation will come together really simply.

    Great news Chip.
    Sorry I haven't been much help this time around.
    Been too busy with getting P1 on chip compilation to work under FAT32 drivers and OS - buried way deep in a few bugs ;)
    Will surface shortly :)

    Sounds good.

    What about using one Prop1 to target another? That way, if the target crashes due to a bug, you don't have to start over. That's how I've envisioned the Prop2 tools, anyway.

    That is easy. All I/O goes via common hub longs (rendezvous locations in top hub ram). The cog drivers can be replaced with serial/video/keyboard or whatever without altering the OS or Compiler. Currently I am using a PCSIO driver which is loaded into a resident cog and communicates to PST running on a PC at 115,200 baud. Absolutely no reason why this cannot be another P1 !

    If the compiler crashes it reboots the P1. It is running under my OS which uses the same indirection. The compiler is a 3 stage (LEX, CODEGEN & LINK) based on Michael Park's Sphinx Compiler, and runs on FAT16/32 using a modified version of Kye's SD_FATEngine. The OS includes Dir (sorted and * substitution), Copy, Ren, Del, Type (with a hex/ascii option too), Hubdump (hex/ascii), Free/Used (SD space), Help, Reboot, Run (a binary file), Program (the EEPROM lower or upper 32KB), Diff (difference between 2 files), and File Transfers between PC and Propeller SD card, etc. It can also read/write (transfer) CPM2.2 format disk files which we can use with the heater's Z80 emulation ZiCog and my RamBlade boards which have 512KB 55ns SRAM.

    The EEPROM contains a simple and generic boot program that looks for two files on the SD card. It loads the first one found. If my OS is present then it will be loaded, if the first file is not found. There is no requirement for a PropPlug as files can be copied to the SD card on the PC.

    Just need to get USB running properly on the P1, and ready for P2 ;)

    That sounds great!
  • cgraceycgracey Posts: 14,155
    edited 2016-04-13 10:15
    All right! I finally got the new release posted at the top of this thread - Version 8.

    Smart pin docs are all updated, too.
  • cgracey wrote: »
    All right! I finally got the new release posted at the top of this thread - Version 8.

    Smart pin docs are all updated, too.

    Exciting!
  • Thanks Chip! :)
  • ozpropdevozpropdev Posts: 2,792
    edited 2016-04-13 11:54
    FYI All
    Just a heads up to a change to the smart pin instruction format
    In version 7z it was
    D/# = %BBBB_AAAA_FFF_PPPPPPPPPPPPP_T_D_MMMMM_1
    and in version 8 it is now
    D/# = %AAAA_BBBB_FFF_PPPPPPPPPPPPP_TT_MMMMM_0
    
    ** Note pin selection position change and bit 0 inversion **
  • Might be good to update the thread title to indicate the new date.
  • cgraceycgracey Posts: 14,155
    David Betz wrote: »
    Might be good to update the thread title to indicate the new date.

    Good idea.
  • ozpropdev wrote: »
    FYI All
    Just a heads up to a change to the smart pin instruction format
    In version 7z it was
    D/# = %BBBB_AAAA_FFF_PPPPPPPPPPPPP_T_D_MMMMM_1
    and in version 8 it is now
    D/# = %AAAA_BBBB_FFF_PPPPPPPPPPPPP_TT_MMMMM_0
    
    ** Note pin selection position change and bit 0 inversion **

    Good catch! That would have caused quite a bit of head scratching!
  • cgracey wrote: »
    UPDATED 13 April 2016 - Smart Pins - Version 8

    Improved smart pins:

    * new edge-capture modes

    Reading about modes %10100 to %10111, I have a few questions:

    * Are there any caveats if A and B point to the same pin?
    * Do you have to pulse DIR to reset Z, or does it reset on PINGETZ also?
    * For the "either edge" modes, is there a way to know which edge was encountered?

    Also, does this mean that the alternate idea of capturing sysclk instead of count was not possible?
  • cgraceycgracey Posts: 14,155
    Seairth wrote: »
    ozpropdev wrote: »
    FYI All
    Just a heads up to a change to the smart pin instruction format
    In version 7z it was
    D/# = %BBBB_AAAA_FFF_PPPPPPPPPPPPP_T_D_MMMMM_1
    and in version 8 it is now
    D/# = %AAAA_BBBB_FFF_PPPPPPPPPPPPP_TT_MMMMM_0
    
    ** Note pin selection position change and bit 0 inversion **

    Good catch! That would have caused quite a bit of head scratching!

    The smart pin section isn't too long - at least, the first part. I recommend everyone read that, along with whatever mode they are interested in.
  • Also, a thought occurred to me about the modes that use $8000_0000 to indicate a timeout. These could all be extended slightly:
    Value           Interpretation
    <$8000_0000     Normal timed event
    =$8000_0000     Timeout
    >$8000_0000     Missed event
    

    In the case of the missed event, bits [30:0] would contain the same value as normal, but for the most recent measurement (or would it be cumulative?). In practice, the value in [30:0] probably won't be much use. Most of the time, the value will simply be used to detect a missed event.
  • cgraceycgracey Posts: 14,155
    Seairth wrote: »
    cgracey wrote: »
    UPDATED 13 April 2016 - Smart Pins - Version 8

    Improved smart pins:

    * new edge-capture modes

    Reading about modes %10100 to %10111, I have a few questions:

    * Are there any caveats if A and B point to the same pin?
    * Do you have to pulse DIR to reset Z, or does it reset on PINGETZ also?
    * For the "either edge" modes, is there a way to know which edge was encountered?

    Also, does this mean that the alternate idea of capturing sysclk instead of count was not possible?

    Modes %101xx wait for the A-edge, then the B-edge. Then, they start over, and wait for A-edge, then the B-edge, again. If the edges are concurrent, it will wait for the next edge of interest. The Z value will be a new measurement, each time.

    There is no way to know which edge came in, though that could be added very easily.

    The sysclk (CT) capture could work. It's just not that way right now. It wouldn't be hard to do.
  • Is there a collection of useful P2 code somewhere? For example, where can I find serial rx/tx code?
  • David Betz wrote: »
    Is there a collection of useful P2 code somewhere? For example, where can I find serial rx/tx code?
    Try this code
    con	'async tx/rx test - FPGA image version 8
    
    	sys_clk = 80_000_000
    	baudrate = 3000000 '115200
    	nco_baud = round(float($1_0000) / (float(sys_clk) / float(baudrate)))
    	bits = 8
    	tx_pin = 62
    	rx_pin = 63
    	
    
    dat		orgh
    		org
    
    
    		pinsetm	#%1_11110_0,#tx_pin
    		pinsetx	##$8000_0000 | nco_baud << 16 | %1_00000 | bits-1,#tx_pin
    		setb	dirb,#tx_pin
    
    		pinsetm	#%1_11111_0,#rx_pin
    		pinsetx	##$8000_0000 | nco_baud << 16 | %1_00000 | bits-1,#rx_pin
    		setb	dirb,#rx_pin
    
    
    main		testb	inb,#rx_pin wc			'wait for char
    	if_nc	jmp	#main
    
    		pingetz	adra,#rx_pin			'get char
    		pinack	#rx_pin
    
    		call	#send_message			'show character
    		mov	bx,adra
    		call	#send_hex_byte
    		mov	bx,#" "
    		call	#send_char
    		mov	bx,adra
    		call	#send_char
    		mov	bx,#13
    		call	#send_char
    		jmp	#main
    
    send_message	loc	ptrb,#@message
    bbb		rdbyte	bx,ptrb++ wz
    	if_z	ret
    		call	#send_char
    		jmp	#bbb
    
    send_char	pingetz	ax,#tx_pin wc			'wait if busy
    	if_c	jmp	#send_char
    		pinsety	bx,#tx_pin
    		ret
    
    send_hex_byte	push	bx
    		shr	bx,#4
    		and	bx,#$f
    		cmp	bx,#9 wz,wc
    	if_a	add	bx,#"A"-10
    	if_be	add	bx,#"0"
    		call	#send_char
    		pop	bx
    		and	bx,#$f
    		cmp	bx,#9 wz,wc
    	if_a	add	bx,#"A"-10
    	if_be	add	bx,#"0"
    		call	#send_char
    		ret
    
    		ret
    ax		res	1
    bx		res	1
    
    dat		orgh	$400
    
    message		byte	"Received character -=> ",0
    


  • ozpropdev wrote: »
    David Betz wrote: »
    Is there a collection of useful P2 code somewhere? For example, where can I find serial rx/tx code?
    Try this code
    con	'async tx/rx test - FPGA image version 8
    
    	sys_clk = 80_000_000
    	baudrate = 3000000 '115200
    	nco_baud = round(float($1_0000) / (float(sys_clk) / float(baudrate)))
    	bits = 8
    	tx_pin = 62
    	rx_pin = 63
    	
    
    dat		orgh
    		org
    
    
    		pinsetm	#%1_11110_0,#tx_pin
    		pinsetx	##$8000_0000 | nco_baud << 16 | %1_00000 | bits-1,#tx_pin
    		setb	dirb,#tx_pin
    
    		pinsetm	#%1_11111_0,#rx_pin
    		pinsetx	##$8000_0000 | nco_baud << 16 | %1_00000 | bits-1,#rx_pin
    		setb	dirb,#rx_pin
    
    
    main		testb	inb,#rx_pin wc			'wait for char
    	if_nc	jmp	#main
    
    		pingetz	adra,#rx_pin			'get char
    		pinack	#rx_pin
    
    		call	#send_message			'show character
    		mov	bx,adra
    		call	#send_hex_byte
    		mov	bx,#" "
    		call	#send_char
    		mov	bx,adra
    		call	#send_char
    		mov	bx,#13
    		call	#send_char
    		jmp	#main
    
    send_message	loc	ptrb,#@message
    bbb		rdbyte	bx,ptrb++ wz
    	if_z	ret
    		call	#send_char
    		jmp	#bbb
    
    send_char	pingetz	ax,#tx_pin wc			'wait if busy
    	if_c	jmp	#send_char
    		pinsety	bx,#tx_pin
    		ret
    
    send_hex_byte	push	bx
    		shr	bx,#4
    		and	bx,#$f
    		cmp	bx,#9 wz,wc
    	if_a	add	bx,#"A"-10
    	if_be	add	bx,#"0"
    		call	#send_char
    		pop	bx
    		and	bx,#$f
    		cmp	bx,#9 wz,wc
    	if_a	add	bx,#"A"-10
    	if_be	add	bx,#"0"
    		call	#send_char
    		ret
    
    		ret
    ax		res	1
    bx		res	1
    
    dat		orgh	$400
    
    message		byte	"Received character -=> ",0
    

    Works perfectly! Thanks!!

  • rjo__rjo__ Posts: 2,114
    Thanks Brian!!!

    I had some problems with copy/paste. It looked ok in PNUTv8, but didn't run right. Second time was a charm.
    So I'm posting your code as an attachment.
  • ozpropdev wrote: »
    FYI All
    Just a heads up to a change to the smart pin instruction format
    In version 7z it was
    D/# = %BBBB_AAAA_FFF_PPPPPPPPPPPPP_T_D_MMMMM_1
    and in version 8 it is now
    D/# = %AAAA_BBBB_FFF_PPPPPPPPPPPPP_TT_MMMMM_0
    
    ** Note pin selection position change and bit 0 inversion **

    It might make sense to rearrange this as follows:
    D/# = %PPPPPPPPPPPPP_FFF_AAAA_BBBB_TT_MMMMM_0
    

    That way, where %PPPPPPPPPPPPP_FFF is zero, PINSETM would take only 6 clocks instead of 10. In half-duplex modes, where you are frequently switching between RX and TX, this could make a difference in maximum bit rate.
  • cgracey wrote: »
    The smart pin section isn't too long - at least, the first part. I recommend everyone read that, along with whatever mode they are interested in.

    I started re-reading the entire document. More than once, I though "I forgot about that!" It's amazing how much more powerful this is compared to the P1. Calling it "P2" really doesn't do it justice!

    Incidentally, I notice that there are still two unused interrupt event sources. It seems a shame to leave them empty. If nothing else, it might make sense to trap reading from or writing to hub address zero (for null pointer detection).
  • rjo__rjo__ Posts: 2,114
    Chip,

    Thank you!!!

    Normally I don't read documentation, because it all looks Greek to me. I'm trying. It is nice having Brian around:)

    Somewhere in there is the answer to this question, but I'll be damned if I can find it.

    It is about Phil's camera. He didn't hook up the actual Hsync signal of the sensor... which is fine. He is using a data pin to indicate both Hsync and the start of each pixel data coming out (in serial snapshot mode). This means that you have to look for a gap in his "hsync-lite" pin to indicate the end of a line and then use the next signal from the same pin to indicate the beginning of the pixel data, which arrives without gaps, 8 bits at a time.

    I handle this currently by just capturing all of the data, using wrfast and ina, and then worry about it later... big buffer:)

    The data is valid on the negative clock(10MHz)... so I can invert this pin, but how do I use that clock with the smartpin in serial mode? Or can I?

  • rjo__rjo__ Posts: 2,114
    It is not a big deal. If it isn't possible, I think I can get my buffer down to about the size of a line... just haven't gotten there yet:)
  • cgraceycgracey Posts: 14,155
    edited 2016-04-13 19:24
    rjo__ wrote: »
    Chip,

    Thank you!!!

    Normally I don't read documentation, because it all looks Greek to me. I'm trying. It is nice having Brian around:)

    Somewhere in there is the answer to this question, but I'll be damned if I can find it.

    It is about Phil's camera. He didn't hook up the actual Hsync signal of the sensor... which is fine. He is using a data pin to indicate both Hsync and the start of each pixel data coming out (in serial snapshot mode). This means that you have to look for a gap in his "hsync-lite" pin to indicate the end of a line and then use the next signal from the same pin to indicate the beginning of the pixel data, which arrives without gaps, 8 bits at a time.

    I handle this currently by just capturing all of the data, using wrfast and ina, and then worry about it later... big buffer:)

    The data is valid on the negative clock(10MHz)... so I can invert this pin, but how do I use that clock with the smartpin in serial mode? Or can I?

    So, you want to do synchronous serial input, but 8 bits wide?

    If that's the case, the streamer would do a much better job than the smart pins, but it needs an external clock input. This is simple to add. Could you post a link to that camera doc, or just the relevant section?
  • cgraceycgracey Posts: 14,155
    edited 2016-04-13 19:21
    Seairth wrote: »
    ozpropdev wrote: »
    FYI All
    Just a heads up to a change to the smart pin instruction format
    In version 7z it was
    D/# = %BBBB_AAAA_FFF_PPPPPPPPPPPPP_T_D_MMMMM_1
    and in version 8 it is now
    D/# = %AAAA_BBBB_FFF_PPPPPPPPPPPPP_TT_MMMMM_0
    
    ** Note pin selection position change and bit 0 inversion **

    It might make sense to rearrange this as follows:Hu
    D/# = %PPPPPPPPPPPPP_FFF_AAAA_BBBB_TT_MMMMM_0
    

    That way, where %PPPPPPPPPPPPP_FFF is zero, PINSETM would take only 6 clocks instead of 10. In half-duplex modes, where you are frequently switching between RX and TX, this could make a difference in maximum bit rate.

    I put it the way it is so that P[7:0] is on a byte boundary, making it easy to set the DAC or comparator value. The P field is 13 bits, which is odd.
  • rjo__rjo__ Posts: 2,114
    a serial file from Phil... remember he is cheating:)

    product info/data sheet

    sensor data sheet

  • RaymanRayman Posts: 14,649
    was hoping to test this real fast, but my serial output code is now broke...
    Something must have changed. Don't think it's the serial output itself, just the code driving it...
    Getting "0"s out instead of numbers and strings...
  • RaymanRayman Posts: 14,649
    edited 2016-04-13 20:12
    ozpropdev's code seems to work though...

    Old (broke):
    send_char
                    pinsety tx_char,#TX_PIN  'send  character
    send_char_wait
                    pingetz temp,#TX_PIN
                    testb   temp,#31 wz,wc    
             if_nz  jmp #send_char_wait
                    ret  wz,wc
    
    Oz (works):
    send_char       pingetz temp,#tx_pin wc                   'wait if busy
            if_c    jmp     #send_char
                    pinsety tx_char,#tx_pin
                    ret wz,wc
    
  • jmgjmg Posts: 15,173
    Seairth wrote: »
    Also, a thought occurred to me about the modes that use $8000_0000 to indicate a timeout. These could all be extended slightly:
    Value           Interpretation
    <$8000_0000     Normal timed event
    =$8000_0000     Timeout
    >$8000_0000     Missed event
    

    In the case of the missed event, bits [30:0] would contain the same value as normal, but for the most recent measurement (or would it be cumulative?). In practice, the value in [30:0] probably won't be much use. Most of the time, the value will simply be used to detect a missed event.

    Yes, the more usual Overflow Flag operation is simply a single sticky bit.
    Other counter bits do not lose information - ie they continue to count.
    (This is probably actually simpler in silicon. )

    I have just used exactly this feature in another MCU, where I know it is going to overflow, but I also know the spread is not large, so I can still calibrate using a timer that overflowed many times in this case.

  • jmgjmg Posts: 15,173
    edited 2016-04-13 20:46
    Seairth wrote: »
    Also, does this mean that the alternate idea of capturing sysclk instead of count was not possible?
    I'm not following this comment.
    From my reading, Time Interval A-B modes are capturing SysCLK units ?

    Or did you mean a method to capture both SysCLK and Count information, which Reciprocal Counting needs.
    I have assumed always that would need 2 pin cells, but that it would be possible.

    A quite similar situation occurs for Duty Cycle capture - you ideally want two numbers, (here they are both dT) that relate to the exact same edge(s)
    Two pin cells should be able to do this ? but can they ?

    What is missing from this Time Interval A-B mode, is a means to handle missed events.
    Users are forced to assume & hope that only one capture occurred.
    A sudden jump in calculated frequency can result, if the dT is actually more than one event.

  • RaymanRayman Posts: 14,649
    I've got serial working again, but getting all zeros from USB status...
Sign In or Register to comment.