AnsweredAssumed Answered

SPI Slave is giving garbage values.

Question asked by hussnain.shafqat on Dec 10, 2014
Latest reply on Dec 11, 2014 by waclawek.jan
I have configured my STM32F407 Discovery Board as slave with a STM8S00. The data sent by Master on MOSI is totally different from that which that my slave is receiving I have observed that data on the Digital Oscilloscope. Setting in the master is as follows: CPHA=1 CPOL=1 Master sends at Negative edge and samples at positive edge. SPI Clock is 4 MHz. It is also sending back different data that sent by a STM32F407 master.
Here is the code of main file:
#include "stm32f4_discovery.h"

int i=0, IT_St=0;
int Rx_Buf[1000];
void SPI_TR(void);;
void n_Tick(int tk);

void n_Tick(int tk)

void SPI_TR(void)
     GPIO_InitTypeDef GPIO_SPI;
     SPI_InitTypeDef My_SPI;
     NVIC_InitTypeDef nvic;
     EXTI_InitTypeDef itr;
     RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);
     RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
     GPIO_SPI.GPIO_Pin=GPIO_Pin_4 | GPIO_Pin_5 |  GPIO_Pin_6 | GPIO_Pin_7;
     GPIO_PinAFConfig(GPIOA, GPIO_PinSource4, GPIO_AF_SPI1);
     GPIO_PinAFConfig(GPIOA, GPIO_PinSource5, GPIO_AF_SPI1);
     GPIO_PinAFConfig(GPIOA, GPIO_PinSource6, GPIO_AF_SPI1);
     GPIO_PinAFConfig(GPIOA, GPIO_PinSource7, GPIO_AF_SPI1);
     RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
     nvic.NVIC_IRQChannelCmd = ENABLE;
     nvic.NVIC_IRQChannelPreemptionPriority= 0;
     My_SPI.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
     My_SPI.SPI_Mode = SPI_Mode_Slave;
     My_SPI.SPI_DataSize = SPI_DataSize_8b;
     My_SPI.SPI_CPHA = SPI_CPHA_2Edge;
     My_SPI.SPI_NSS = SPI_NSS_Hard; // Configure it make high to low transition
     My_SPI.SPI_FirstBit = SPI_FirstBit_MSB;
     SPI_Init(SPI1, &My_SPI);
     SPI_Cmd(SPI1, ENABLE);
void SPI1_IRQHandler()
     SPI_I2S_ClearFlag(SPI1, SPI_I2S_FLAG_RXNE);
     SPI_I2S_ClearITPendingBit(SPI1, SPI_I2S_IT_RXNE);

int main(void)