THE WAKE UP CHANNEL
Go to bottomPage: 1
TOPIC:
#889
problem with SPI 1 Year, 6 Months ago Karma: 0
void SPI_SendData(unsigned char data)
{
volatile unsigned char transmisja;

//SPICTL &= ~SPIEN; // WYLACZENIE SPI
//SPICTL |= SPIEN; // URUCHOMIENIE SPI

SPIDATA = data;

while ((SPISTAT & TXST_FULL) == 0x00) //Wait for Transmit Buffer Full
;

while ((SPISTAT & TXST_FULL) == TXST_FULL) //Wait for Transmit Buffer Empty
;

}

When I try use this funciton program sometimes works fine and sometines stops in while loops. I cant resolve this problem.
I am trying works with SPI w interrupt mode but or me wrong to it or SPI is bullshit in encore.

How should look routine to works with interrupts?
mezon (User)
Fresh Boarder
Posts: 18
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#890
Re:problem with SPI 1 Year, 6 Months ago Karma: 4
Mezon,
I am not sure which Encore part you are working with, however, on the I would check for Receive Data Register Not Empty instead of Transmit Data Register Empty.
Typically when I do an SPI_Send() for the ESPI parts:

//Assuming SS select is already selected
void Send_SPI()
{
ESPIDATA = i;

while ( (ESPISTAT & 0x80) == 0); //wait for it to transmit

while ( (ESPISTAT & 0x04) == 0); // and receive gets populated from loop

}

To implement the SPI with interrupts, see associated product specifications for information on how to enable the interrupts for the family you are using, write your interrupt handler to handle the interrupts.
Tom Ormiston (Admin)
Admin
Posts: 168
graph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#891
Re:problem with SPI 1 Year, 6 Months ago Karma: 0
I am working with Z8F0822.
mezon (User)
Fresh Boarder
Posts: 18
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
Go to topPage: 1
Ткани купить, ткани для одежды , купить ткани киев