[AVR] [SPIMEM]Unrecegnized Command Code[48] , [00], [08]

Status
Not open for further replies.

ronakmirkhany

Newbie level 2
Joined
Oct 29, 2014
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
17
Hi,
Dear Friends,
I'm new in using SPI, and i am writing data via SPI from ATMEGA32 to an eeprom m95160.

i fallowed the datasheet but i think i have some misunderstanding parts, so i receive those errors in the title, would you please help me to debug my code?

compiler is : codevisionAVR
simulator: proteus

actually this master code workes for 2 micros. I'm in running my project time and I'm hanged. pleaseeeeeeeeeeeeee help me.


Code dot - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
PORTA.5 = 1;
PORTA.6 = 1;
PORTB.4 = 1;
while (1)
      { 
      if(PIND.2 == 0)  //this is a key to push
      {      
      
            PORTA.5 = 0; // W' of the eeprom is driven to LOW
            PORTA.6 = 0; //a LED G ON
            PORTB.4 = 0; //SS' of the slave select
          
            
            //WREN 
            SPSR.7 = 1;
            SPDR = 00000110;     
            while(SPSR.7 == 0);
            
            //WRITE 
            SPSR.7 = 1;
            SPDR = 00000010;     
            while(SPSR.7 == 0); 
            
            //ADD  
            SPSR.7 = 1;      //address in the eeprom to write
            SPDR = 0x00 >> 8;   
            SPDR = 0x00;
            while(SPSR.7 == 0);  
            
            //data  
            SPSR.7 = 1;
            SPDR = 'H'; 
            while(SPSR.7 == 0);   
            //while(!((SPSR)&(1<<7)));      
           
           
            PORTB.4 = 1;
      }
      else
      {
            PORTA.6 = 1; 
            PORTA.5 = 1;
      }
 
}



: bsdetector:
 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…