Color LCD via SW/HW SPI on AVR

 \r\n\r\n \r\n\r\nI played with the AVR HW SPI, and wanted to use this for a purpose.\r\n\r\nI had earlier been doing some code for a color LCD running a SPI mode, but not using HW SPI. Instead I did the SW just by bit-banging both Clock and Data pins.\r\n\r\nTo find out exactly how much faster the HW SPI is I wrote following code:\r\n\r\n


\r\n\r\nint main(void)\r\n{\r\nchar x;\r\n\r\n// Running bit-banging SW SPI\r\n\r\nSpiFlagEnabled = 0;\r\navr_init();\r\nLcdInit();\r\n\r\n for(x=0; x<32; x++) //31.2sec\r\n{\r\nFillRect(0, 0, 128, 128, BLACK);\r\nFillRect(0, 0, 128, 128, WHITE);\r\nFillRect(0, 0, 128, 128, BLUE);\r\nFillRect(0, 0, 128, 128, RED);\r\n}\r\n\r\n\r\n// Running HW SPI \r\n\r\n SpiFlagEnabled = 1;\r\navr_init();\r\nLcdInit();\r\n\r\nfor(x=0; x<32; x++) //18.0sec\r\n{\r\nFillRect(0, 0, 128, 128, BLACK);\r\nFillRect(0, 0, 128, 128, WHITE);\r\nFillRect(0, 0, 128, 128, BLUE);\r\nFillRect(0, 0, 128, 128, RED);\r\n}\r\n}\r\n\r\n

\r\n\r\n \r\n\r\nThe code is doing a loop 32 times, with 4 complete screen updates each loop. First everything is made with SW SPI. This took 31.2 seconds. Afterwards The HW SPI was initialized and set to run the same loop. Time was down to 18 seconds.\r\n\r\nI recorded a video with the above code. The change on SW and HW SPI is happening after 34 seconds. The video is 5.2MB\r\n\r\n\r\n\r\n \r\n\r\n \r\n\r\n \r\n\r\n \r\n\r\n \r\n\r\n \r\n\r\n \r\n\r\n \r\n\r\n \r\n\r\nConclusion on SW vs. HW SPI is 43% faster for HW SPI. And this test only concentrates on writing to the LCD. If the uC had other tasks the HW SPI could do other tasks while the data byte is shifted on to the LCD.\r\n\r\n 




Skriv et svar

Din e-mail-adresse vil ikke blive offentliggjort. Krævede felter er markeret med *

Disse HTML koder og attributter er tilladte: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Go to Top