Spi on HSC12C

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Spi on HSC12C

2,387 Views
RChapman
Contributor I
This message contains an entire topic ported from a separate forum. The original message and all replies are in this single message. We have seeded this new forum with selected information that we expect will be of value to you as you search for answers to your questions.
 
Posted: Thu Feb 03, 2005 3:37 pm  
 
Hi all,

I'm a newbe here, so I thought I should try my luck
solving a basic simple problem of mine.

I have configured two controllers, HCS12C128, to communicate on the SPI. One as master, and the other as slave.

My problem is that I can't figure out how to return data from the slave.
I read the status register and then write to the data register, as the manual says, but I always receive the previously transmitted data in the master.

Thanks in advance,
Posted: Fri Feb 04, 2005 8:02 am    
 
I had forgotten to set the CPHA-bit. Embarassed
 
Posted: Fri Apr 22, 2005 4:54 pm    
 
Glad you found your solution. Strange thing is, I'm having the same problem, but I have the CPHA bit set. As far as I can tell, I have the other registers set where they need to be as well.

How did you set your other SPI registers? I'm thinking I might be missing a bit setting somewhere.

Posted: Mon Apr 25, 2005 6:16 am    

I keep the slave pulled down all the time.

In the master, the SPE, MSTR, and CPHA-bits of SPICR1 are set. SPICR0 is 0. I set the SPTIE and SPIE- bits right after the first byte is transmitted.

In the slave, the SPIE, SPE, MSTR, and CPHA-bits are set. SPICR0 is 0.

I also found that the slave data does not clock its data until the third byte. Maybe there's something I have missed that causes this, but I can live with it. I use sync and key data to detect messages anyway.

Moreover, you have to make sure that both ends are initialised before transmission begins.

Good luck!

 

Labels (1)
0 Kudos
0 Replies