Go Down

Topic: Setup DDRB, SPCR,PORTB for connect RAM 32k with Arduino MEGA???? (Read 2292 times) previous topic - next topic

legoritmo

Hi! I´m trying to connect an external memory RAM 32KB with Arduino MEGA. I connect it with Arduino Duemilanove and I got it, but now I want to do it with the MEGA, and I have to configure the pins MOSI, MISO, CLK and SS (11,12,13,10 in Duemilanove) for to use it with Arduino MEGA.
This is how is defined in the SRAM library (Duemilanove):

#define setupSPI SPCR = 0x50 //Master mode, MSB first, SCK phase low, SCK idle low, clock/4
#define setupDDRB DDRB |= 0x2c  //set  SCK(13) MOSI(11) and SS as output
#define selectSS PORTB &= ~0x04  //set the SS to 0 to select
#define deselectSS PORTB |= 0x04  //set the SS to 1 to deselect

And my question is, which address do I have to change for to use it with MEGA device??I found this, but it doesn´t work.


#define setupSPI SPCR = 0x2c //Master mode, MSB first, SCK phase low, SCK idle low, clock/4
#define setupDDRB DDRB |= 4  //set  SCK(13->52) MOSI(11->  51) and SS as output
#define selectSS PORTB &= ~5  //set the SS to 0 to select
#define deselectSS PORTB |= 5  //set the SS to 1 to deselect


Thank you everyone!


Go Up