Esd Lab - 9
Esd Lab - 9
Esd Lab - 9
KRISHNA KANT
EVD19I001
30-3-23
Objective
SSI Initialization :
Initialize LCD write function :
Algorithm for 6 bit DAC :
• The timer of cortex M-4 microcontrollers are utilized to create time delays
and generate periodic interrupts.
• It's based on a 24-bit down counter with an auto reload, which is called
“current”, which counts down at the bus clock frequency.
• It can be configured following 3 registers:
o SysTick Control and Status (STCTRL)
o SysTick Reload Value (STCTRL)
o SysTick Current Value (STCTRL)
GPIO MODULE:
• It stands for General Purpose Input Output Module
• The GPIO module gives access to the user to interface sensors and actuators
with the processor
• In TIVA TM4C123GH6PM Launch Pad there are 43 programmable input/output
pins divided into 6 ports.
• The Port F has an onboard LED connected and there are two onboard switches
that are connected in negative logic.
RUN MODE CLOCK GATING CONTROL REGISTER 2 (RCGC2):
• This register controls the clock gating logic in normal Run mode.
• Each bit, if set, the corresponding module receives a clock and functions.
• Otherwise, the module is un-clocked and disabled.
#include "tm4c123gh6pm.h"
#include <stdint.h>
#include "PLL.h"
enum typeOfWrite{
COMMAND, // the transmission is an LCD command
DATA // the transmission is data
};
//********Nokia5110_Init*****************
// Initialize Nokia 5110 48x84 LCD by sending the proper
// commands to the PCD8544 driver. One new feature of the
// LM4F120 is that its SSIs can get their baud clock from
// either the system clock or from the 16 MHz precision
// internal oscillator.
// inputs: none
// outputs: none
// assumes: system clock rate of 80 MHz
void Nokia5110_Init(void){
volatile uint32_t delay;
SYSCTL_RCGC1_R |= 0x00000010; // activate SSI0
SYSCTL_RCGC2_R |= 0x00000001; // activate port A
delay = SYSCTL_RCGC2_R; // allow time to finish activating
GPIO_PORTA_DIR_R |= 0xC0; // make PA6,7 out
GPIO_PORTA_AFSEL_R |= 0x2C; // enable alt funct on PA2,3,5
GPIO_PORTA_AFSEL_R &= ~0xC0; // disable alt funct on PA6,7
GPIO_PORTA_DEN_R |= 0xEC; // enable digital I/O on
PA2,3,5,6,7
GPIO_PORTA_PCTL_R = (GPIO_PORTA_PCTL_R&0xFF0F00FF)+0x00202200; //
configure PA2,3,5 as SSI
GPIO_PORTA_PCTL_R = (GPIO_PORTA_PCTL_R&0x00FFFFFF)+0x00000000; //
configure PA6,7 as GPIO
GPIO_PORTA_AMSEL_R &= ~0xEC; // disable analog functionality on
PA2,3,5,6,7
SSI0_CR1_R &= ~(0x00000002); // disable SSI
SSI0_CR1_R &= ~(0x00000004); // master mode
// configure for system clock/PLL baud clock source
SSI0_CC_R &= ~(0x0000000F);
// clock divider for 3.33 MHz SSIClk (80 MHz PLL/24)
// SysClk/(CPSDVSR*(1+SCR))
// 80/(24*(1+0)) = 3.33 MHz (slower than 4 MHz)
SSI0_CPSR_R = (SSI0_CPSR_R&~(0x000000FF))+24; // must be even number
SSI0_CR0_R &= ~(0x0000FFF0); // SCR = 0 (3.33 Mbps data rate) // SPH = 0 //
SPO = 0
//********Nokia5110_Clear*****************
// Clear the LCD by writing zeros to the entire screen and
// reset the cursor to (0,0) (top left corner of screen).
// inputs: none
// outputs: none
void Nokia5110_Clear(void){
int i;
for(i=0; i<(MAX_X*MAX_Y/8); i=i+1){
lcddatawrite(0x00);
}
Nokia5110_SetCursor(0, 0);
}
//********Nokia5110_DrawFullImage*****************
// Fill the whole screen by drawing a 48x84 bitmap image.
// inputs: ptr pointer to 504 byte bitmap
// outputs: none
// assumes: LCD is in default horizontal addressing mode (V = 0)
void Nokia5110_DrawFullImage(const uint8_t *ptr){
int i;
Nokia5110_SetCursor(0, 0);
for(i=0; i<(MAX_X*MAX_Y/8); i=i+1){
lcddatawrite(ptr[i]);
}
}
int main(void){
}
Output
EXERCISE
#include "tm4c123gh6pm.h"
#include <stdint.h>
#include "PLL.h"
enum typeOfWrite{
COMMAND, // the transmission is an LCD command
DATA // the transmission is data
};
//********Nokia5110_Init*****************
// Initialize Nokia 5110 48x84 LCD by sending the proper
// commands to the PCD8544 driver. One new feature of the
// LM4F120 is that its SSIs can get their baud clock from
// either the system clock or from the 16 MHz precision
// internal oscillator.
// inputs: none
// outputs: none
// assumes: system clock rate of 80 MHz
void Nokia5110_Init(void){
volatile uint32_t delay;
SYSCTL_RCGC1_R |= 0x00000010; // activate SSI0
SYSCTL_RCGC2_R |= 0x00000001; // activate port A
delay = SYSCTL_RCGC2_R; // allow time to finish activating
GPIO_PORTA_DIR_R |= 0xC0; // make PA6,7 out
GPIO_PORTA_AFSEL_R |= 0x2C; // enable alt funct on PA2,3,5
GPIO_PORTA_AFSEL_R &= ~0xC0; // disable alt funct on PA6,7
GPIO_PORTA_DEN_R |= 0xEC; // enable digital I/O on PA2,3,5,6,7
GPIO_PORTA_PCTL_R = (GPIO_PORTA_PCTL_R&0xFF0F00FF)+0x00202200; //
configure PA2,3,5 as SSI
GPIO_PORTA_PCTL_R = (GPIO_PORTA_PCTL_R&0x00FFFFFF)+0x00000000; //
configure PA6,7 as GPIO
GPIO_PORTA_AMSEL_R &= ~0xEC; // disable analog functionality on PA2,3,5,6,7
SSI0_CR1_R &= ~(0x00000002); // disable SSI
SSI0_CR1_R &= ~(0x00000004); // master mode
// configure for system clock/PLL baud clock source
SSI0_CC_R &= ~(0x0000000F);
// clock divider for 3.33 MHz SSIClk (80 MHz PLL/24)
// SysClk/(CPSDVSR*(1+SCR))
// 80/(24*(1+0)) = 3.33 MHz (slower than 4 MHz)
SSI0_CPSR_R = (SSI0_CPSR_R&~(0x000000FF))+24; // must be even number
SSI0_CR0_R &= ~(0x0000FFF0); // SCR = 0 (3.33 Mbps data rate) // SPH = 0 //
SPO = 0
//********Nokia5110_SetCursor*****************
// Move the cursor to the desired X- and Y-position. The
// next character will be printed here. X=0 is the leftmost
// column. Y=0 is the top row.
// inputs: newX new X-position of the cursor (0<=newX<=11)
// newY new Y-position of the cursor (0<=newY<=5)
// outputs: none
void Nokia5110_SetCursor(uint8_t newX, uint8_t newY){
if((newX > 11) || (newY > 5)){ // bad input
return; // do nothing
}
// multiply newX by 7 because each character is 7 columns wide
lcdwrite(COMMAND, 0x80|(newX*7)); // setting bit 7 updates X-position
lcdwrite(COMMAND, 0x40|newY); // setting bit 6 updates Y-position
}
//********Nokia5110_Clear*****************
// Clear the LCD by writing zeros to the entire screen and
// reset the cursor to (0,0) (top left corner of screen).
// inputs: none
// outputs: none
void Nokia5110_Clear(void){
int i;
for(i=0; i<(MAX_X*MAX_Y/8); i=i+1){
lcddatawrite(0x00);
}
Nokia5110_SetCursor(0, 0);
}
//********Nokia5110_DrawFullImage*****************
// Fill the whole screen by drawing a 48x84 bitmap image.
// inputs: ptr pointer to 504 byte bitmap
// outputs: none
// assumes: LCD is in default horizontal addressing mode (V = 0)
void Nokia5110_DrawFullImage(const uint8_t *ptr){
int i;
Nokia5110_SetCursor(0, 0);
for(i=0; i<(MAX_X*MAX_Y/8); i=i+1){
lcddatawrite(ptr[i]);
}
}
int main(void){
}
Output
Results
• A Synchronous serial interface (SSI) module is used to interface the Tiva
microcontroller to a Nokia5110 LCD and an image of choice is successfully
displayed using the given LCD