spirilis 1,265 Posted June 29, 2013 Share Posted June 29, 2013 I've extended the Energia SPI library to support 9-bit SPI on all MSP430-based platforms. Tested on G2452 and G2553 so far, I don't have a FRaunchpad so I can't test it there at the moment. I trust that it should work based on a code comparison with the G2553 USCI implementation though. SPI class contains the .transfer9() function which takes & returns an unsigned 16-bit integer containing a right-shifted 9-bit value. The 9th bit is implemented natively on USI platforms (with appropriate shifting sensitive to MSB-first vs LSB-first operation of the USISR 16-bit register) but it uses a custom software bit-bang approach for the 9th bit on USCI platforms. The code to implement this is a bit ugly but knock on wood, it seems to work. Supports all 4 SPI clock phase/polarity modes too. The purpose behind this modification is to support LCD displays that require 9-bit SPI, as many do when they are configured to forego the use of a dedicated Data/Control line in lieu of the 8th bit of each SPI packet indicating D/C. This effort was taken to support the Nokia 1202 LCD display, available cheap online from chinese vendors (~$1.50/pc for a 96x68 pixel B&W LED-backlit display with DIY solderable 0.6mm pitch SMD connector) but happens to include an STE2007 controller wired for 9-bit SPI operation. Github site: https://github.com/spirilis/SPI Release tested on G2553 and G2452: SPI_9bit.zip This should unzip a "SPI" directory which you may place in your home profile's libraries/ subdir, e.g. ~/Documents/Energia/libraries on the Mac. Energia should preferentially use this version over its own app-installed version for all future SPI calls. No modifications were made to the normal 8-bit SPI implementation. TraHoangSon 1 Quote Link to post Share on other sites
TraHoangSon 0 Posted October 29, 2014 Share Posted October 29, 2014 Thank you! Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.