03.08.2013 Views

S.N.A.K.E.: A Dynamically Reconfigurable Artificial Sensate Skin ...

S.N.A.K.E.: A Dynamically Reconfigurable Artificial Sensate Skin ...

S.N.A.K.E.: A Dynamically Reconfigurable Artificial Sensate Skin ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

C:\Documents and Settings\Gerardo\My Documents\Work\SM (MIT)\Thesis\Code\Firmware\I2C_Master.s43<br />

C:\Documents and Settings\Gerardo\My Documents\Work\SM (MIT)\Thesis\Code\Firmware\I2C_Master.s43<br />

; Interrupt Vectors Used MSP430x13x/14x/15x/16x<br />

;------------------------------------------------------------------------------<br />

ORG 0FFFEh ; MSP430 RESET Vector<br />

DW RESET ;<br />

ORG 0FFE2h ; P2 Interrupt vector<br />

DW USB_TX_ISR ;<br />

ORG 0FFF0h ; I2C interruplt vector<br />

DW I2C_ISR ;<br />

BIS.B #I2CSTT+I2CSTP+I2CTRX,&I2CTCTL ; Initiate transfer<br />

MOV.B #RESET_SKIN_INST, R5 ; Indicate a reflash instruction<br />

CALL #I2C_SEND_BYTE ; Send instruction<br />

RETI<br />

END<br />

//EXECUTE SKIN CODE INSTRUCTION<br />

Execute<strong>Skin</strong>Code<br />

BIC.B #I2CEN,&U0CTL ; Reconfigure I2C<br />

BIC.B #XA,&U0CTL ; Reconfigure I2C<br />

BIC.B #I2CRM,&I2CTCTL ; ACLK<br />

BIS.B #I2CEN,&U0CTL ; Recommended init procedure<br />

MOV #0,&I2CSA ; RESET ALL NODES!<br />

MOV.B #1, &I2CNDAT<br />

BIS.B #MST,&U0CTL ; Master mode<br />

BIS.B #I2CSTT+I2CSTP+I2CTRX,&I2CTCTL ; Initiate transfer<br />

MOV.B #EXECUTE_CODE_INST, R5 ; Indicate a reflash instruction<br />

CALL #I2C_SEND_BYTE ; Send instruction<br />

RETI<br />

StartSampling<br />

CLR R6<br />

CALL #USB_GET ; Get byte<br />

CALL #USB_SEND ; echo<br />

MOV.B R5, Address(R6)<br />

CALL #USB_GET ; Get byte<br />

CALL #USB_SEND ; echo<br />

INC R6<br />

MOV.B R5, Address(R6)<br />

BIS.B #80h, I2CFlags<br />

RETI<br />

StopSampling<br />

BIC.B #80h, I2CFlags<br />

RETI<br />

End_USB_TX_ISR<br />

RETI<br />

;------------------------------------------------------------------------------<br />

I2C_ISR; Common ISR for I2C Module<br />

;------------------------------------------------------------------------------<br />

ADD &I2CIV,PC ; Add I2C offset vector<br />

RETI ; No interrupt<br />

RETI ; Arbitration Lost<br />

RETI ; No Acknowledge<br />

RETI ; Own Address<br />

RETI ; Register Access Ready<br />

JMP RXRDY_ISR ; Receive Ready<br />

RETI ; Transmit Ready<br />

RETI ; General Call<br />

RETI ; Start Condition<br />

RXRDY_ISR<br />

MOV.B &I2CDRB,R5 ; RX data in R5<br />

bic.B #LPM0,0(SP) ; Clear LPM0<br />

RETI<br />

;------------------------------------------------------------------------------<br />

Page 8 of 8<br />

Page 7 of 8

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!