From d407747ab5989bd21e0a5d04a223aeb1bf16747e Mon Sep 17 00:00:00 2001 From: Victor Accarini Date: Mon, 20 Apr 2015 14:07:28 -0400 Subject: [PATCH] SPI working --- main.c | 2 -- mem.c | 50 +++++++++++++++++++++++++++++++++++++------------- 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/main.c b/main.c index a50c0fd..fa08526 100644 --- a/main.c +++ b/main.c @@ -65,10 +65,8 @@ int main(void) // while(1) // { - _delay_ms(1); _Enable_SPI(); _SPI_Send_Data(0x0000,0x33); - _SPI_Send_Data(0x0000,0x33); (*ADC_DataAddress) = _SPI_Receive_Data(0x0000); //Input command //getLine(str); diff --git a/mem.c b/mem.c index 5b30cf1..76f1901 100644 --- a/mem.c +++ b/mem.c @@ -99,19 +99,27 @@ void _SPI_Transmit(unsigned char Data) void _SPI_Send_Data(unsigned int Address, unsigned char Data) { + unsigned char temp; + //Chip Select Down + _delay_us(10); PORTB &= ~(1 << PB4); + _delay_us(10); /* Start transmission */ SPDR = SPI_WriteEnable; /* Wait for transmission complete */ while (!(SPSR & (1<