Wondering is this correct?

Discussion in 'Homework Help' started by shanemib, Nov 16, 2016.

  1. shanemib

    Thread Starter New Member

    Nov 16, 2016
    2
    0
    Hi this is my question, I'm wondering have I got it right, close or am I completely wrong?
    Write a fragment of code in C to write to the SPCR and SPSR registers of the ATMega328P microcontroller to set it up for the following operation:

    • SPI Enabled
    • LSB transmitted first
    • Master SPI Mode selected
    • Rising edge is the Leading edge
    • Setup on the Leading Edge, sample on the Trailing Edge
    • SPI2X disabled, SCK frequency = fosc/64.
    • SPI Interrupt Enable selected
    (You may ignore the SPIF and WCOL bits).
    You may also assume the existence of the macro sei() to enable global interrupts. Include this in your program fragment in the correct place.

    My answer:

    SPCR = 0b11110110;
    SPSR = 0;
    sei();
     
  2. shteii01

    AAC Fanatic!

    Feb 19, 2010
    4,436
    703
    Datasheet?
     
  3. shanemib

    Thread Starter New Member

    Nov 16, 2016
    2
    0
  4. jpanhalt

    Expert

    Jan 18, 2008
    6,451
    1,252
    Looks OK to me.

    John
     
Loading...