I've got a Nokia LCD shield that is working perfectly fine as long as it is the only device sitting on an ARDUINO.
I am now trying to make the Nokia LCD shield (A) work together with another board in development (B).
Both boards (A & B) use the SPI bus where SCLK, MOSI and MISO PINs are shareable. Also both boards use PIN 10 - but I need to keep PIN 10 reserved for the board in development(B).
Therefore I am trying to relocate PIN 10 for the NOKIA LCD shield (A) to some other PIN available.
At the moment I can make out 2 options (other suggestions are most welcome):a)
Move PIN 10 to digital PIN 4
with the aid of GPIO, move PIN 10 to analogue PIN 4.
Let's look at option a)
The NOKIA LCD shield uses the library 'PCF8833.h' where PIN definitions currently occur like in the code below:
/* Pin definition for Arduino boards */
#define CS 10
#define CLK 13
#define DATA 11
#define RESET 9
#define BL_ON 8
#define LCD_CS(x) PORTB= (x)? (PORTB|(1<<PB2)) : (PORTB&~(1<<PB2))
#define LCD_CLK(x) PORTB= (x)? (PORTB|(1<<PB5)) : (PORTB&~(1<<PB5))
#define LCD_DATA(x) PORTB= (x)? (PORTB|(1<<PB3)) : (PORTB&~(1<<PB3))
#define LCD_RESET(x) PORTB= (x)? (PORTB|(1<<PB1)) : (PORTB&~(1<<PB1))
#define LCD_BACKLIGHT(x) PORTB= (x)? (PORTB|(1<<PB0)) : (PORTB&~(1<<PB0))
What would be the code for LCD_CS(x) to move from PB2 (PIN 10) to PD3 (PIN 4)?
I have tried to change the code for LCD_CS like below, but this did not work.
#define LCD_CS(x) PORTD= (x)? (PORTD|(1<<PD3)) : (PORTD&~(1<<PD3))
What would be the proper syntax to move PIN 10 to PIN 4?Option b)
make use of GPIO:
I was told that:
The SS pin for SPI port, is the slave select pin. It is used when the ATMEGA168 is used as a SPI slave. In your case, the ATMEGA168 is used as a SPI master, so you can choose any GPIO pin as a SPI select pin. Just pull the GPIO pin low, before you do SPI transmission; and pull it high, when SPI finish transmission.
Meanwhile by searching and reading the I/O tutorials I understand both options in principle, but I have not much idea how to write the code so that it functions properly, especially since PIN 10 is defined in the library for the NOKIA LCD shield.
The solution envisioned is nicely published in Wikipedia describing the SPI bus.http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus#Daisy_chain_SPI_configuration
Suggestions for either solution a) or b) are most welcome.
Thanks for questions and feedback, Hans.