Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Wondering is this correct?

  • 16-11-2016 11:13PM
    #1
    Registered Users, Registered Users 2 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