Hi,
I am checking SPI Transmit and receive using 2 KEA-128 Development Board.I am using one TRK-KEA128 board for transmit and another TRK-KEA-128 Board for receive. I am not able to get it right. I have attached the code for both SPI Transmit and receive Below.
I am using Port E for both connections are
Master Slave
PTE0 -> PTE0 (SPI_SCK -> SPI_SCK)
PTE1 -> PTE2 (MOSI -> MISO)
PTE3 -> PTE3 (SS -> SS)
I have made only these connections, is it enough or do i need to do more connections?
I am not able to receive any data.I am seeing it on debug mode in spi_d global variable for the receive code to validate this.
Can you tell me what things I have to change to make SPI Transmit and receive work???
Original Attachment has been moved to: SPI_Master_Transmit.zip
Original Attachment has been moved to: SPI_slave_KEA_128.zip
Hi VIGNESH BALAJI,
1. About the sample code
Please refer to your another post, I already give you the SPI sample code:
Please refer to the official code, and check your own code.
2. SPI connection
Your connection is wrong.
Master slave
MISO MISO
MOSI MOSI
SS SS
CLK CLK
You can't connect the MOSI in master to slave MISO, you should connect MOSI in master to the MOSI in slave.
This is very important.
Wish it helps you!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Kerry,
I understood the connections, what I wanted to know here is Whether the code that I have attached for SPI_Transmit and SPI_receive are they right????
Can you cross check them and say me ????
Hi VIGNESH BALAJI,
Your code have some errors.
Master:
1. select the SSEL as the SPI select pin instead of just GPIO.
SPI0_C1 |= SPI_C1_SSOE_MASK;
SPI0_C2 |= SPI_C2_MODFEN_MASK;
2. enable the PTE0, PTE1,PTE2,PTE3 pull up for working stable.
PORT_PUE1 |= PORT_PUE1_PTEPE0_MASK | PORT_PUE1_PTEPE1_MASK|PORT_PUE1_PTEPE2_MASK|PORT_PUE1_PTEPE3_MASK;
3. After enter main file, add a small delay for the power on stable.
int main(void){
unsigned int i,j;
Clk_Init();
SPI_init();
for(i=0;i<100;i++) for(j=0;j<65535;j++); // delay, wait for the system stable
for(;;) {
SPI_write(0x21);
uint8_t spi_d = SPI_read();
}
return 0;
}
Slave:
1. select the SSEL as the SPI select pin instead of just GPIO.
SPI0_C1 &= ~SPI_C1_SSOE_MASK;
SPI0_C2 |= SPI_C2_MODFEN_MASK;
2. enable the PTE0, PTE1,PTE2,PTE3 pull up for working stable.
PORT_PUE1 |= PORT_PUE1_PTEPE0_MASK | PORT_PUE1_PTEPE1_MASK|PORT_PUE1_PTEPE2_MASK|PORT_PUE1_PTEPE3_MASK;
Then after connect two KEA128 together, it will work fine.
I have test your code on my TRK KEA128 board, it works ok.
Slave debug result:
Slave can receive the correct data 0x21 from master.
Logic analyzer wave:
I also attached my modified project for your reference.
Wish it helps you!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------