This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430F5438A 与 AT25DF641(Flash)SPI 模式 传输数据

Other Parts Discussed in Thread: MSP430F5438A

大家好!

我需要MSP430F5438A 与AT25DF641(Flash)SPI 模式 传输数据。对SPI模式进行了配置,根据AT25DF641(Flash)写数据的说明写了一段最简单的从flash读取数据的程序,即先传Read的opcode,再传Read的3位起始地址,再有一个Dummy Byte之类,然后说明讲在接下来时钟到来就会从Flash读出数据了。可是我的程序就是不对,我预计R6中应该每次都是FF,但是我单步调试,似乎是随机数。没有发过类似的技术咨询帖,以下把我的试验程序放在这里,请大家指导。

           bis.b   #0x80,&P1DIR            ; Set P1.7(CS pin) to output direction

           bis.b   #0x80,&P1OUT

           bis.b   #0x31,&P3SEL            ; P3.5,4,0 option select

           bis.b   #UCSWRST,&UCA0CTL1      ; **Reset USCI state machine**

           bis.b   #UCMST + UCSYNC  + UCMSB,&UCA0CTL0

                                           ; 3-pin, 8-bit SPI master

                                           ; Mode 0, MSB

           bis.b   #UCSSEL_2,&UCA0CTL1     ; SMCLK

           mov.b   #0x02,&UCA0BR0          ; /2

           mov.b   #0x00,&UCA0BR1

           mov.b   #0x00,&UCA0MCTL         ; No modulation

           bic.b   #UCSWRST,&UCA0CTL1      ;**Initialize USCI state machine**

           bis.b   #UCRXIE,&UCA0IE         ; Enable USCI_A0 RX interrupt

Read_Flash  mov.w   #200,R8

           bic.b   #0x80,&P1OUT            ; Assert CS pin to select Flash Memory

           mov.b   #0x0B,&UCA0TXBUF        ; Send 0Bh -> TXBUF, ie. the Read Array command

Wait8       bit.b   #UCTXIFG,&UCA0IFG       ; USCI_A0 TX buffer ready?

           jnc     Wait8

           mov.b   #0x00,&UCA0TXBUF        ; Send 3-byte Starting Address -> TXBUF

Wait9       bit.b   #UCTXIFG,&UCA0IFG       ; USCI_A0 TX buffer ready?

           jnc     Wait9

           mov.b   #0x00,&UCA0TXBUF

Wait10      bit.b   #UCTXIFG,&UCA0IFG       ; USCI_A0 TX buffer ready?

           jnc     Wait10

           mov.b   #0x00,&UCA0TXBUF

Wait11      bit.b   #UCTXIFG,&UCA0IFG       ; Send a Dummy Byte  -> TXBUF

           jnc     Wait11                  ; USCI_A0 TX buffer ready?

           mov.b   #0x00,&UCA0TXBUF

           bis.w   #LPM3 + GIE,SR          ; Enter LPM3, enable interrupts

           nop                             ; For debugger

;************************************************************************************

USCI_A0_ISR

;************************************************************************************

           add.w   &UCA0IV,PC              ; Vector to interrupt handler

           reti                            ; Vector 0: No interrupt

           jmp     RXIFG_HND               ; Vector 2: RXIFG

           reti                            ; Vector 4: TXIFG

RXIFG_HND

           mov.b   &UCA0RXBUF,R6           ; RXBUF -> R6

           dec.w   R8

           jz      Read_Finish

           reti

Read_Finish bis.b   #0x80,&P1OUT            ; Deassert CS pin to finish the read Array command

           bic.b   #UCRXIE,&UCA0IE         ; Enable USCI_A0 RX interrupt

           reti

;************************************************************************************

; Interrupt Vectors

;************************************************************************************

           .sect   ".int57"

           .short  USCI_A0_ISR

           .end