I have Problems with my SPI-communication. When i am debug my program, what is based on Lab12b, i get the following error.
C28xx: Trouble Writing Memory Block at 0xbac1 on Page 0 of Length 0x1: (Error -1142 @ 0xBAC2) Device blocked debug access because it is currently executing non-debuggable code. Choose 'Rude Retry' to disable polite mode and force the operation. (Emulation package 5.1.507.0)
When i am comment my SPI-function the programm works without any error. The Master is the MCU and the Slave is a FPGA. First i want to read one single Register (1 Byte) from the FPGA with a function.
Here are my SPI functions:
/* Send one byte and get one back */ void HAL_SPI_TransReceive(HAL_Handle handle, uint8_t *transdata, uint8_t *receivedata) //----- { HAL_Obj *obj = (HAL_Obj *)handle; SPI_Obj *spiA = (SPI_Obj *)obj->spiAHandle; SPI_write(spiA,*transdata); while(1) //Warten bis Übertragung abgeschlossen { if(SPI_getIntFlagStatus(spiA)==SPI_IntFlagStatus_Completed) { *receivedata=(uint_least8_t) SPI_read(spiA); break; } } return; } /*read a register*/ void ReadSingleReg(HAL_Handle handle, uint8_t reg_addr, uint8_t *receivedata) { HAL_Obj *obj = (HAL_Obj *)handle; SPI_Obj *spiA = (SPI_Obj *)obj->spiAHandle; uint_least16_t onlinestatus=0x0000; reg_addr=((0x80)||(reg_addr)); spiA->SPICTL|=0x02; // Chip Select Setzen HAL_SPI_TransReceive(handle,®_addr,receivedata); onlinestatus=(uint_least16_t)*receivedata; onlinestatus=onlinestatus<<(7); reg_addr=0x3F; HAL_SPI_TransReceive(handle,®_addr,receivedata); onlinestatus=(uint_least16_t)*receivedata; HAL_SPI_TransReceive(handle,®_addr,receivedata); spiA->SPICTL&=0xFD; // Chip Select Rücksetzen return; }
my SPI configuration is:
void HAL_setupSpiA(HAL_Handle handle) { HAL_Obj *obj = (HAL_Obj *)handle; SPI_reset(obj->spiAHandle); SPI_setMode(obj->spiAHandle,SPI_Mode_Master); SPI_setClkPolarity(obj->spiAHandle,SPI_ClkPolarity_OutputRisingEdge_InputFallingEdge); SPI_setClkPhase(obj->spiAHandle,SPI_ClkPhase_Normal); SPI_enableTx(obj->spiAHandle); SPI_enableTxFifoEnh(obj->spiAHandle); SPI_enableTxFifo(obj->spiAHandle); SPI_setTxDelay(obj->spiAHandle,0x0018); SPI_setBaudRate(obj->spiAHandle,(SPI_BaudRate_e)(0x0003)); SPI_setCharLength(obj->spiAHandle,SPI_CharLength_8_Bits); SPI_setSuspend(obj->spiAHandle,SPI_TxSuspend_free); SPI_enable(obj->spiAHandle); return;
}
What is the reason of my failure? I hope somebody could help me.
I am calling the function in the MainISR:
ReadSingleReg(halHandle, version, &SPI_Receivedata);