How to coordinate with Smartpin in NCO mode? IN not working?

RaymanRayman Posts: 9,125
edited 2019-01-14 - 15:40:56 in Propeller 2
I have pin#1 toggling using Smartpin in NCO mode like this:
'Turn on pixel clock
            mov     x,##SmartMode
            wrpin   x,#PClkPin
            mov     x,##$0D  '1.2 MHz with $0D, 9.62 MHz with wypin=$8000_0000
            wxpin   x,#PClkPin
            mov     x,##$1000_0000'8000_0000  'Toggle every n base period
            wypin   x,#PClkPin
            dirh    #PClkPin

Then, I'm trying to make pin#0 follow the output using testp on the smartpin like this:
TestLoop
            nop
            nop
            testp   #PClkPin wc 
    if_nc   drvh    #DePin
    if_c    drvl    #DePin                                                        
            nop
            nop
            jmp     #TestLoop

Doesn't work though, seems in on smartpin is always high...
What am I doing wrong?
Prop Info and Apps: http://www.rayslogic.com/

Comments

  • ElectrodudeElectrodude Posts: 1,238
    edited 2019-01-14 - 18:43:14
    The IN, OUT, and DIR lines of a pin don't mean what they normally mean when the smartpin is in a non-zero mode. See the smartpin documentation for what they do mean in each mode. It would seem from the documentation that IN is raised on every accumulator overflow and drops again when you AKPIN or WRPIN the pin.

    Also, unrelated to your problem, you can replace this:
        if_nc   drvh    #DePin
        if_c    drvl    #DePin
    
    with this:
                drvnc    #DePin
    

    EDIT: ACKPIN -> AKPIN
  • Thanks! Akpin (new name, right?) is what I needed to do. That wasn't so clear...
    This now produces a pulse on DePin every time PClkPin goes low:
    TestLoop            
                nop
                nop
                testp   #PClkPin wc 
                akpin   #PClkPin
                drvc    #DePin                                                      
                nop
                nop
                jmp     #TestLoop
    
    Prop Info and Apps: http://www.rayslogic.com/
  • I may need to try bit-banging the pixel clock too...

    This works fine at 1 MHz, but at 10 MHz only catches every 5th pulse:
    TestLoop            
                testp   #PClkPin wc 
                drvc    #DePin   
                akpin   #PClkPin                                                   
                jmp     #TestLoop
    
    Prop Info and Apps: http://www.rayslogic.com/
  • @rayman

    You can use the smart pin input selector to read the output state of neighbor pins.
    From the smart pin docs:

    D/# = %AAAA_BBBB_FFF_PPPPPPPPPPPPP_TT_MMMMM_0

    %AAAA: ‘A’ input selector

    0xxx = true (default)
    1xxx = inverted
    x000 = this pin’s read state (default)
    x001 = relative +1 pin’s read state
    x010 = relative +2 pin’s read state
    x011 = relative +3 pin’s read state
    x100 = this pin’s OUT bit from cogs
    x101 = relative -3 pin’s read state
    x110 = relative -2 pin’s read state
    x111 = relative -1 pin’s read state
    Here's an example of reading a smart pins output state.
    dat	org
    
    	hubset	#1		'rcslow
    
    	wrpin	#%1_00110_0,#56	'nco frequency mode
    	wxpin	##10000,#56	'base period
    	wypin	##$80000000,#56
    	dirh	#56
    
    	wrpin	##%1111 << 28,#57	'input selector = inverted, pin - 1
    
    	rep	#2,#0			'repeat forever
    	testp	#57 wc			'get pin 56 state
    	drvc	#59			'send inverted state to pin 59
    
    
    Melbourne, Australia
Sign In or Register to comment.