The project aims to create a program to shows a scoreboard on the microcontrolle
ID: 3655409 • Letter: T
Question
The project aims to create a program to shows a scoreboard on the microcontroller. The following program is my menu to shows the scoreboard,please help me check my program
scoreboard layout
Program:
#include <p18f46K20.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include "delays.h"
#include "oled_interface.h"
#include "oled_jib.h"
#include "oled_cmd.h"
#include <math.h>
#define switch1 PORTBbits.RB0
#define switch2 PORTBbits.RB1
#define switch3 PORTBbits.RB2
#define switch4 PORTBbits.RB3
enum type {main,Home_Team,Guests_Team};
char echo[100];
unsigned int argument[6];
int x=0,y=0,m=0,n=0;
//x, y stand for two teams score and m,n stand for match
/************* D E C L A R A T I O N S *******************/
void InitializeSystem(void);
void scoreboard(void);
unsigned char scoreboard(void);
int Getkey(void); //A blocking function that waits for a key to be pressed. This function handles the [MENU] key.
void InitializeSystem(void);
void main(void)
{
char temp;
int x,y,m,n;
int x=0;
int y=0;
int m=0;
int n=0;
enum type state = MAIN;
InitializeSystem();
delay = 30000;
while(delay--);
// These are the functions you need to use to initialise the display
oled_init();
oled_clear();
oled_refresh();
//Type the match of sports event
typedef struct
{
char scoreHome_Team; //Home team win in the period
char scoreGuests_Team;
}match_t;
//Type the points of sports event in one match
typedef struct
{
char Home_Teamn; //Home team got 1 point in the match
char Guests_Teamn;
match_t match[7]; // Maximum 7 matches
}score_t;
}
while (1)
{
switch(state)
{
case (MAIN):
{
Delay10KTCYx(250);
oled_clear();
oled_fixeds_1x("Team Period Digits Home Guest");
oled_refresh();
} break;
Explanation / Answer
; put data in RAM MOV 30H, #'0' MOV 31H, #'0' MOV 32H, #'0' MOV 33H, #'0' MOV 34H, #0; end of data marker ; initialise the display ; see instruction set for details CLR P1.3 ; clear RS - indicates that instructions are being sent to the module ; function set CLR P1.7 ; | CLR P1.6 ; | SETB P1.5 ; | CLR P1.4 ; | high nibble set SETB P1.2 ; | CLR P1.2 ; | negative edge on E CALL delay ; wait for BF to clear ; function set sent for first time - tells module to go into 4-bit mode ; Why is function set high nibble sent twice? See 4-bit operation on pages 39 and 42 of HD44780.pdf. SETB P1.2 ; | CLR P1.2 ; | negative edge on E ; same function set high nibble sent a second time SETB P1.7 ; low nibble set (only P1.7 needed to be changed) SETB P1.2 ; | CLR P1.2 ; | negative edge on E ; function set low nibble sent CALL delay ; wait for BF to clear ; entry mode set ; set to increment with no shift CLR P1.7 ; | CLR P1.6 ; | CLR P1.5 ; | CLR P1.4 ; | high nibble set SETB P1.2 ; | CLR P1.2 ; | negative edge on E SETB P1.6 ; | SETB P1.5 ; |low nibble set SETB P1.2 ; | CLR P1.2 ; | negative edge on E CALL delay ; wait for BF to clear ; display on/off control ; the display is turned on, the cursor is turned on and blinking is turned on CLR P1.7 ; | CLR P1.6 ; | CLR P1.5 ; | CLR P1.4 ; | high nibble set SETB P1.2 ; | CLR P1.2 ; | negative edge on E SETB P1.7 ; | SETB P1.6 ; | SETB P1.5 ; | SETB P1.4 ; | low nibble set SETB P1.2 ; | CLR P1.2 ; | negative edge on E CALL delay ; wait for BF to clear ; send data SETB P1.3 ; clear RS - indicates that data is being sent to module MOV R1, #30H ; data to be sent to LCD is stored in 8051 RAM, starting at location 30H loop: MOV A, @R1 ; move data pointed to by R1 to A JZ finish ; if A is 0, then end of data has been reached - jump out of loop CALL sendCharacter ; send data in A to LCD module INC R1 ; point to next piece of data JMP loop ; repeat finish: JMP $ sendCharacter: MOV C, ACC.7 ; | MOV P1.7, C ; | MOV C, ACC.6 ; | MOV P1.6, C ; | MOV C, ACC.5 ; | MOV P1.5, C ; | MOV C, ACC.4 ; | MOV P1.4, C ; | high nibble set SETB P1.2 ; | CLR P1.2 ; | negative edge on E MOV C, ACC.3 ; | MOV P1.7, C ; | MOV C, ACC.2 ; | MOV P1.6, C ; | MOV C, ACC.1 ; | MOV P1.5, C ; | MOV C, ACC.0 ; | MOV P1.4, C ; | low nibble set SETB P1.2 ; | CLR P1.2 ; | negative edge on E CALL delay ; wait for BF to clear delay: MOV R0, #50 DJNZ R0, $ RET
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.