Simulating SPI with AVR Studio

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hi all,

I am trying to program a simple SPI application using Atmel's
ATTiny2313. I lifted the code straight out of their guide:

SPITransfer_Fast:
out USIDR,r16
ldi r16,(1<<USIWM0)|(0<<USICS0)|(1<<USITC)
ldi r17,(1<<USIWM0)|(0<<USICS0)|(1<<USITC)|(1<<USICLK)
out USICR,r16 ; MSB
out USICR,r17
out USICR,r16
out USICR,r17
out USICR,r16
out USICR,r17
out USICR,r16
out USICR,r17
out USICR,r16
out USICR,r17
out USICR,r16
out USICR,r17
out USICR,r16
out USICR,r17
out USICR,r16 ; LSB
out USICR,r17
in r16,USIDR
ret

However, when I try and run this code in the AVR simulator, I am not
observing any changes on PB6 (or any of the PORTB pins, for that
matter). I am pretty sure I set DDRB coorectly to configure UCSK/DO as
output.

Has anyone had any success simulating SPI with AVR Studio ? If so, any
ideas on what I might be doing wrong ?


Re: Simulating SPI with AVR Studio
I'm using a atmega8 but I think it works the same. This is my code,

SPI_Send:

                  out   SPDR,r16
Wait:
                  sbis  SPSR,SPIF   ; Wait for transmission to complete
                  rjmp  Wait

  ret

I'm using avr studio for simulation.


SFC


Quoted text here. Click to load it



Re: Simulating SPI with AVR Studio
Quoted text here. Click to load it



No, the USI and the SPI are two different peripherals.
The USI can be used to emulate an SPI.



--
Best Regards,
Ulf Samuelsson
We've slightly trimmed the long signature. Click to see the full one.
Re: Simulating SPI with AVR Studio
So you have to bit bang it then?

SFC

Quoted text here. Click to load it



Re: Simulating SPI with AVR Studio
Quoted text here. Click to load it

The USI is an 8 bit shift register where the clock can be be software
controlled
You write an 8 bit value to the shift register and then
you write 8 times to an I/O location to clock it out.
You can also use timers to clock the USI.

Bit banging involves several I/O writes per bit.

Quoted text here. Click to load it

--
Best Regards,
Ulf Samuelsson
We've slightly trimmed the long signature. Click to see the full one.
Re: Simulating SPI with AVR Studio

Quoted text here. Click to load it

The AVR studio 4.11 build 401 help file clearly tells in the known issues
USI is not yet supported.

Jeroen



Site Timeline