Menu

Which AVR instruction will be used for <something> spcr0 c!

2016-12-05
2016-12-05
  • Jindrich Vavruska

    Hello, I have some problem with SPI module and want to make sure I have the correct information for further investigation...

    When I do this:
    $50 $4c c! \ ( initializing SPI in master mode by writing to SPCR0)
    what is the actual instruction performed? Is it OUT or ST, or something else?

    Thank you,

    Jindra

    P.S. my SPI behaves oddly. I configure the /SS pin (PORTB:2) as output but when I enable SPI in master mode, the pin goes to tri-state as input and I cannot change it until I disable SPI again. I think the same applies to MISO (PORTB:4). This causes some pin shortage in my application, so I am trying to find the cause. Before I ask at avrfreaks forum, I would like to be sure what is the instruction causing this.

     
  • Mikael Nordman

    Mikael Nordman - 2016-12-05

    Hi,
    c! is using

    st Z, r24
    
     

    Last edit: Mikael Nordman 2016-12-05
  • Mikael Nordman

    Mikael Nordman - 2016-12-05

    I have no problems. How do you see that /SS becomes an input ?

    2c ddrb c!  ok<$,ram> 
    50 spcr c!  ok<$,ram> 
    spcr c@ . 50  ok<$,ram>
    spsr c@ . 0  ok<$,ram> 
    12 spdr c!  ok<$,ram> 
    spsr c@ . 80  ok<$,ram> 
    spcr c@ . 50  ok<$,ram> 
    ddrb c@ . 2c  ok<$,ram> 
    
     
  • Jindrich Vavruska

    I connect a LED with a resistor to the pin. As soon as I enable SPI, it goes off. PORTB and DDRB, however, show what I have previously written to them.

    I have just checked once more - I think I swapped /SS and MISO. Nevertheless the problem is there. /SS pin is OK, but MISO switches to input after setting SPEN :-(

     

Log in to post a comment.