Recently I tried to interface Atmega168A microcontroller with 25LC256 SPI EEPROM. The hex file I created using Atmel Studio 7 work as expected in Proteus simulation. But when I interfaced it with real EEPROM the UART in not working properly. When I comment out the SPI initialization function and do UART communication alone every thing work fine. The AVR is working in internal 8Mhz crystal oscillator with CLKDIV8 fuse bit unprogrammed to get full 8MHZ clock speed. UART work properly without initializing the SPI protocol. At first I used setbaud.h library to initialize UART, later after finding problem I commented out and manually enter baud rate by reffering to datasheet given value for baud rate of 9600. One thing to notice is that without calling SPI initialization function the UART work very well when using setbaud.h and by manually setting baud rate. I attached all codes *.c files including main, SPI and UART header files and the *.hex file too. So any body can test this circuit or can run a simulation on any other software. I tried several ways but cannot find any clue. Need Help from you guys.
Below is the image showing EEPROM data read and write successfully in Proteus simulation.