Please make this assembly code into C, this file setups the LCD and allow you to
ID: 3878571 • Letter: P
Question
Please make this assembly code into C, this file setups the LCD and allow you to draw pixels, refresh the screen ect when the function(LCD_Pixel) or (LCD_Refresh) etc is called.
if the image does not show up, (view in order)
http://imgur.com/a/mUEG4
http://imgur.com/a/27cma
http://imgur.com/a/61h4z
http://imgur.com/a/AODja
http://imgur.com/a/194Vk
http://imgur.com/a/nGccB
INCLUDE Registers.s AREA DATA, ALIGN-2 LCDmat SPACE 1056 AREA LCDCODE, CODE, READONLY, ALIGN=2 EXPORT LCD_Init EXPORT LCD_Cmd_Out EXPORT LCD_Dat_Out IMPORT DelayMs EXPORT LCD_Contrast EXPORTLCD Pixel EXPORT LCD Refresh EXPORT LCD Blank CSbit EQU 0x80 RSTbit EQU 0x40 A0bit EQU 0x20 CLKbit EQU 0x20 DATbit EQU 0x10 CSport EQU 0x400043FC RSTport EQU 0x400043FC A0port EQU 0x400043FC CLKport EQU 0x400243FC DATport EQU 0x400243FC LCD_Init ; assuming CSwrite pin0, RSTwrite pin1 PUSH LR, R0-R4) LDR RO,-CSport LDR R1, [R0] BIC R1, #(CSbit) STR R1, [R0] LDR Re, -RSTport LDR R1, [R0] BIC R1, #(RSTbit) STR R1, [R0] MOV R3, #70 BL DelayMs LDR R1, [R0] ORR R1, #(RSTbit) STR R1, [R0] MOV R3, #70 BL DelayMs ; GPIO-DATA &= ~1 CSwrite(0) ; GPIO-DATA &= ~2 RSTwrite(0) ; DelayMs (50ms) ; GPIO DATA I-2 RSTwrite(1)Explanation / Answer
#include <LiquidCrystal.h>
void InsertCharacter(unsigned char *LCD_Character) //the input to this function is a pointer to a pixel data array
{
unsigned char n;
unsigned char row_pixel;
unsigned char column_byte;
//rows are handled on a pixel-by-pixel basis
row_pixel = LCDCursor[ROW];
//columns are handled on a byte-by-byte basis, because one character width is 8 bits
column_byte = LCDCursor[COL];
/*each byte from the pixel data array is copied to LCDDisplayData,
starting with the current cursor position*/
for(n = 0; n < CHAR_HEIGHT; n++)
{
LCDDisplayData[row_pixel][column_byte] = *LCD_Character;
LCD_Character++; //point to the next byte in the array
row_pixel++; //the next byte corresponds to pixel data for the next line
}
LCDCursor[COL]++; //move the cursor one character width to the right
/*if the cursor has reached the end of the line,
return the cursor to the far left and move it
down by one character height*/
if(LCDCursor[COL] == NUM_LINE_DATA_BYTES)
{
LCDCursor[COL] = 0;
LCDCursor[ROW] = LCDCursor[ROW] + CHAR_HEIGHT;
if(LCDCursor[ROW] == NUM_LINES) //if the cursor has reached the end of the display area,
LCDCursor[ROW] = 0; //return the cursor to the top line
}
while(UPDATE_LCD == FALSE); //wait here until Timer2 initiates an LCD update
UPDATE_LCD = FALSE;
UpdateAllLCDLines();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.