So im doing a home project where im using an ATMEGA 2560. The goal is to send data from the MOSI to the MISO on the same board.
Im having some problems with how to attack this.
So far my code looks like this:
Moderators note : Used code tags for C
Im having some problems with how to attack this.
So far my code looks like this:
C:
#include <avr/io.h>
#include "I2C.h"
#include "ssd1306.h"
#define F_CPU 16000000UL
#include <util/delay.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <avr/interrupt.h>
#include "Initialize Display.h"
#include "Setup display.h"
void setup(); //setting up display for later use
unsigned char cData;
unsigned char SPI_MasterTransmit(unsigned char Cdata)
{
SPDR = cData; //starter transmissionen
while(!(SPSR & (1<<SPIF))); //venter på transmission bliver færdig
return(SPDR);
}
int main(void)
{
void init_disp(); //display for later use
void SPI_Masterinit(void)
{
DDRB = (1<<PB0) | (1<<PB1) | (1<<PB2) | (0<<PB3); // DDRB er registeret der passer til SPI. med !SS, SCK, MOSI, MISO.
SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR0); //for at enable interrupt sættes (1<<SPIE); the SPRx is for setting the clock
unsigned char cData;
while (1)
{
}
}
Last edited by a moderator: