release SPCR

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

I have my SPCR set up like so.

SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR1)|(1<<SPR0)|(1<<DORD)|(1<<CPHA)|(1<<CPOL);

I send commands over PB3 ( atmega168). The line is normally held LO by the device in which I communicate with. I need to find a way to temporally hold it HI. I figure I could just set the direct and port on PB3 but that is not working ( the device keeps it LO ). Since I communicate to this device I know the single goes HI and LO. I would assume there is just a pull down on the device end. So I'm wondering if there is a way abusing the SPCR to achieve this.

The device does not hold the pin until its initialized. As far as I can tell there is no way to shut down the device. I tried disabling the SPCR but the device just infinitely waits.

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

Try a gate? Or you can disable the SPI until you need to use it and then enable it again, a bit messy though.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

The design is live so a gate is out. I tried to disable the spi in two way

SPCR = (1<<0)|(1<<0)|(1<<0)|(1<<0)|(1<<0)|(1<<0)|(1<<0);

and

SPCR = 0;

the later seem to freeze the device, I dont see how they are different? the former didnt do the trick.

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

Quote:

I dont see how they are different?

One sets bit 0 the other does not.

However as bit 0 is probably SPR0 I don't see what difference it would make.

BTW returning to the original problem - presumably the AVR has control of the peripherals slave select (maybe _CS?) line? If you de-assert the select does the device not tristate the data and clock lines then?

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

Well in analyzing the protocol I could achieve what I want by pulling clock low. As soon as the clock goes lo the line is Hi. Problem is I can not set that bit, my "guess" is because the SPI is using it? If I try to tamper with disable the SPI my spi-burner has issues. and my device freezes. Takes a bit of fooling to reprogram.

If I set jut the 7,6th bits of the SPI to 0 I dont have issue but I still can not control the PORTB.

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

ahh got the bastard!
I simulated the an spi transmission putting 0xff on the command line. This held it Hi long enough to test the pin.