This is a quick introduction that shows how to interface the LPC845 Breakout Board with an OLED display based on the popular SSD1306 controller, using SDK drivers for SPI. With this application, you can print a text string or draw a bitmap image. SPI Protocol The Serial Peripheral Interface (SPI) protocol is asynchronous serial data standard, primarily used to allow a microprocessor to communicate with other microprocessors or ICs such as memories, liquid crystal diodes (LCD), analog-to-digital converter subsystems, etc. The SPI is a very simple synchronous serial data, master/slave protocol based on four lines: • Clock line (SCLK) • Serial output (MOSI) • Serial input (MISO) • Slave select (SS) Adafruit Monochrome OLED Graphical Display This display is made of 128x64 individual white OLED pixels, each one is turned on or off by the controller chip. Because the display makes its own light, no backlight is required. This reduces the power required to run the OLED and is why the display has such high contrast; we really like this miniature display for its crispness! OLED Display Example NXP provides an example package for the LPC845 Breakout that includes projects to use the principal's peripherals that the board include: ADC, I2C, PWM, USART, Captouch, and SPI What we need: LPC845 Breakout Board MCUXpresso IDE V10.3.0 SDK_2.5.0_LPC845 NXP example package OLED Display from Adafruit (also available via NXP distributors) LCD assistant software to convert bitmaps Micro USB cable Once downloaded, we import the library project into the workspace using the ''Import project(s) from file system... from the Quickstart panel in MCUXpresso IDE: Figure 1. Import Projects. Then browse the examples packages archive file: Figure 2. Select Example Package. Press next, and see that are a selection of projects to import, in this case, only keep select the LPC845_BoB_OLED how it looks in the picture below: Figure 3. Select the OLED Project. Press finish and the project example shows up in the workspace: Figure 4. OLED Project in workspace. Create Bitmaps Bitmap (BMP) is an image file format that can be used to create and store computer graphics. A bitmap file displays a small dots in a pattern that, when viewed from afar, creates an overall image. A bitmap image is a grid made of rows and columns where a specific cell is given a value that fills it in or leaves it blank, thus creating an image out of the data. First, you have to create the image using any kind of graphics software such a paint, Photoshop, etc and save the picture as Monochrome Bitmap (bmp), make sure that the image size match whit the OLED size. Figure 5. Save picture as Bitmap. Now inside the LCD software assistant, this program will help us to convert an image from Bitmap to data array, we have to load the image by click on file >> load image, and select the appropriate size. Figure 6. LCD Assistant To import the array go to file >> save the output, choose the place where are going to save. Then inside the example, go to fsl_Font5x7.h and paste the array. Figure 7. Data Array. *Note: Inside the example, the array for the NXP logo is already there, if you want another image, delete this array and pas the new. Connections Now, with the project already in the workspace, it is time to set up the connection between the LPC845 Breakout board and the OLED Display. The table below shows which LPC845 Breakout pin are routed each line of the SPI interface and the pins for reset and Data/Command select. Table 1. Connections. You can check the Datasheet of the board, of bases on the picture below to see where the pin are, note that GND and 3.3V also needed for the OLED display: Figure 8. LPC845 Breakout to OLED Connection. Debug. Now, with the demo in the workspace and the connections done, connect a micro USB cable from connector CN2 to a host computer and debug the application. Figure 9. Run example
記事全体を表示