SPI on XMEGA

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

I have worked with AVR for may years but are new to SPI on Xmega.

The prolem is that I dont have any signal on the SCK pin.

My setup is
// Set up SPI
SPID.CTRL |= SPI_ENABLE_bm | SPI_MASTER_bm | SPI_MODE_2_gc| SPI_PRESCALER_DIV16_gc;
SPID.INTCTRL = SPI_INTLVL_OFF_gc ; // no interrupt
PORTD.DIRSET = PIN7_bm; //Set pin 7 out - SCK
PORTD.OUTSET = PIN4_bm;
PORTD.DIRSET = PIN4_bm; //Set pin 4 out - CS

I understand that the result can be read as:

result = SPID.DATA ;

Anyway, writing to the port sets the IF status flag so the data should have been sent.

Anybody knows the reason and have a solution?

Thanks.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

result = SPID.DATA ;

But even on a non-X that would not cause SCK's? The only way to generate SCKs is to assign a value to SPDR (SPID.DATA) on the master.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks.

It works now and I understand SPI.