cancel
Showing results for 
Search instead for 
Did you mean: 

display driver

joemccarr
Senior
Posted on January 03, 2016 at 16:18

I have the nucleo board and an add-on board with a 2x12 oled character display. Writing to the display is not straight forward because D7..D0 lines are connected to pins on different  ports (PA,PB,PC).

 

Is there a way to structure this hardware so I can write clean C code? 

For instance RS is PB3, WR is PC1, Enable is PA10, D7 is PA8, D6 is PB10, D5 is PB4, D4 is PB5, D3 is PA9, D2 is PC7, D1 is PA3, D0 is PA2. 

Thanks

#port-pins
1 REPLY 1
Posted on January 03, 2016 at 18:39

Is there a way to structure this hardware so I can write clean C code? 

Manage the data pin output in a single function so the complication is abstracted from all the other code?

Either use a table driven method, bit mapping, or use a shift/masking technique for contiguous bits.

GPIO_WriteBit(GPIOA, GPIO_Pin_2, (x & 1));

GPIO_WriteBit(GPIOA, GPIO_Pin_3, (x & 2));

...

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..