Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Wondering is this correct?

Options
  • 16-11-2016 11:13pm
    #1
    Registered Users Posts: 58 ✭✭


    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();


Advertisement