This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

memeory settings FX2

I have implemented an SPI interface in Cypress FX2. I have problems in giving the XDATA and CODE. I gave the settings as CODE - 0X80-0X0fff and XDATA 0X1000. But when I program it ,Iam not able to see the SCLK. IS anything wrong with the memory settings .
Thanks.
Vanitha

Parents
  • I have code for spibytewrite only .Iam using PORT E.PE.0 is my SCLK and PE.7 is my SDO and PE.3 is my CS.

    ?PR?SPIWRITEBYTE?MODULE segment code
     ?DT?SPIWRITEBYTE?MODULE segment data overlayable
    
     PUBLIC _spiwritebyte, ?_spiwritebyte?BYTE
    
     rseg ?DT?SPIWRITEBYTE?MODULE
     ?_spiwritebyte?BYTE:
     d: ds 1
    
     rseg ?PR?SPIWRITEBYTE?MODULE
    
     CLKHIGH equ 00000001B ;Bitmask to turn clk pin high
     CLKLOW equ  11111110B ;Bitmask to turn clk pin low
     BITHIGH equ 10000000B ;Bitmask to turn out pin high
     BITLOW equ  01111111B ;Bitmask to turn out pin low
    
     IOE XDATA 0xB1 ;7F98H
    
     _spiwritebyte:
    
     mov DPTR,#IOE ;point to IOE
     mov R6, #8 ;set up loop
     loop:
     mov A, R7 ;move data to send to A
     rrc A ;rotate left through carry to send LSB first
     mov R7, A ;save rotated
     movx A, @DPTR ;setup to change bit
     jc highbit ;if bit is high jump
     anl A, #BITLOW ;else set bit low
     sjmp skip ;skip setting bit high
     highbit:
     orl A, #BITHIGH ;set out high and clock
     skip:
     orl A, #CLKHIGH ;set clock bit high
     movx @DPTR, A ;output data
     nop ;may need this to stretch clock high time
     anl A, #CLKLOW ;set clock low
     movx @DPTR, A ;output low clock
     djnz R6, loop ;repeat eight times
     ret
     end
    


    Vanitha

Reply
  • I have code for spibytewrite only .Iam using PORT E.PE.0 is my SCLK and PE.7 is my SDO and PE.3 is my CS.

    ?PR?SPIWRITEBYTE?MODULE segment code
     ?DT?SPIWRITEBYTE?MODULE segment data overlayable
    
     PUBLIC _spiwritebyte, ?_spiwritebyte?BYTE
    
     rseg ?DT?SPIWRITEBYTE?MODULE
     ?_spiwritebyte?BYTE:
     d: ds 1
    
     rseg ?PR?SPIWRITEBYTE?MODULE
    
     CLKHIGH equ 00000001B ;Bitmask to turn clk pin high
     CLKLOW equ  11111110B ;Bitmask to turn clk pin low
     BITHIGH equ 10000000B ;Bitmask to turn out pin high
     BITLOW equ  01111111B ;Bitmask to turn out pin low
    
     IOE XDATA 0xB1 ;7F98H
    
     _spiwritebyte:
    
     mov DPTR,#IOE ;point to IOE
     mov R6, #8 ;set up loop
     loop:
     mov A, R7 ;move data to send to A
     rrc A ;rotate left through carry to send LSB first
     mov R7, A ;save rotated
     movx A, @DPTR ;setup to change bit
     jc highbit ;if bit is high jump
     anl A, #BITLOW ;else set bit low
     sjmp skip ;skip setting bit high
     highbit:
     orl A, #BITHIGH ;set out high and clock
     skip:
     orl A, #CLKHIGH ;set clock bit high
     movx @DPTR, A ;output data
     nop ;may need this to stretch clock high time
     anl A, #CLKLOW ;set clock low
     movx @DPTR, A ;output low clock
     djnz R6, loop ;repeat eight times
     ret
     end
    


    Vanitha

Children