actually i want to write something TO the Master. If i send something like : void sendValue (signed short int value) { unsigned char UpperByte = (unsigned char) (value >> 8); unsigned char LowerByte = (unsigned char) (value >> 0); //Value is Transmitted in bit 14:3 // while (SPI_GetFlagStatus(SPI_FLAG_TXE) == RESET); //!!!!!first bit (bit 15) doesnt care) SPI_SendData(UpperByte); // while (SPI_GetFlagStatus(SPI_FLAG_TXE) == RESET); //!!!!!last three bits (bit 2:0) doesnt care) SPI_SendData(LowerByte); } it sends the UpperByte twice. One time in the first 8 clock cycles and the second time in the second 8 clock cycles.
Posted on May 17, 2011 at 15:12 Ok, this should work. I guess the problem was that the interna Clockl f_Master was set to Clock/8 by default (HSIDIV = 8). My application has a SPI-Frequency of 2Mhz. The problem is that the highest frequency of SPI can only set to f_Master/2, which means i could only reach 1Mhz. I switched to 16Mhz High Speed External Oscillator no Prescaler to solve this problem. while (SPI_GetFlagStatus(SPI_FLAG_TXE) == RESET) lines need to be uncommented!!!