SPI on ATXMEGA32A4 PORT D

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

Hello,

I am interfacing with PIC MCU via SPI. I am sending 32 bits of data to the PIC. I have configured SPID on PORTD as a slave and the SPI port on the PIC is the master. The XMEGA is reading and processing data from an ADC and conveys it to the PIC. When a packet of data is ready, the PIC expects the MISO pin (PD6) to go low. It then initiates the data transfer.

The problem is with PD6. I set it as an output:
PORTD.DIRSET = SPI_MISO_bm;
And then toggle it high
PORTD.OUTSET = SPI_MISO_bm;
to let the PIC know that data is not ready. I later toggle it low
PORTD.OUT &= ~SPI_MISO_bm;
when the data is ready.

When I probe PD6 with my DMM, it is always low (0.001V or so). If I don't configure the SPID, PD6 goes high and low as expected. But if SPID is on, the functionality seems to be lost. I am using an AvrDrago and can toggle the pins directly: same thing, if SPID is on, PD6 doesn't budge from 0V.

When the SPID is on, PD6 is in tri-state. So maybe my DMM is pulling it low. But this doesn't seem to be right since the DMM has a pretty high input impedance.

I am not sure why PD6 is acting this way.

Thank you,
Dmitry

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

If you want the Xmega to initiate a data transfer make it the SPI master and the PIC the slave.

Stealing Proteus doesn't make you an engineer.

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

By enabling SPI module in slave mode, MISO function overrides normal pin function and this pin cannot be used as a general IO.

Ozhan KD
Knowledge is POWER

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

ArnoldB,

Thank you for your reply.

That would be great! But I didn't write the PIC firmware and can't alter it. It is looking for a slave. Essentially, the Xmega is a bridge for at LTC2492 ADC chip (http://www.linear.com/product/LT...). I am adding some other capabilities in the Xmega but as far as the PIC is concerned, it is talking to the ADC chip. So I have to mimic the ADC's behavior with the Xmega. That's why I have to mess with the MISO pin.

Dmitry

Last Edited: Wed. Mar 9, 2011 - 07:47 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ozhan,

Thanks for the reply. I feared that this might be the case.

Can you think of a way to work around this?

Dmitry

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

dmitry1001 wrote:
Ozhan,

Thanks for the reply.

Since you didn't thank me, I assume you don't want to have a suggestion from me. Fine with me.

Stealing Proteus doesn't make you an engineer.

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

ArnoldB,

Sorry for my bad manners. I am very thankful for your input and modified my original post to express my thanks.

Dmitry