Scoreboard display on LCD (edsim51)
Mon Nov 29 2010, 10:48 pm
Hello! I'm currently learning the basics of microcontrollers and was given the task of creating a scoreboard to display on the LCD (so 4 digits) and have switches to increment and decrement each displayed digit in assembly. So something like:
0000
Switch 1 and 2, decrements and increments the first digit, 3 and 4 for the second... so on and so forth.
Hitting switch 2 from this point would show: 1000
Switch 4 woudl show: 1100
Etc.
I've figure out how to output to the LCD (thanks to the edsim51 examples) so that my program shows "0000" when run, but I'm not sure how to implement the rest of my code.
I'm not asking how to be spoon fed how to do it but more like I could use some guidance. Would it be possible to use the "switch banks" on the screen to do this? There ARE 8 of them. And do I have to use interrupts to increment and decrement the counters?
If it's of any help here's the code I have written to display "0000" on the LCD:
0000
Switch 1 and 2, decrements and increments the first digit, 3 and 4 for the second... so on and so forth.
Hitting switch 2 from this point would show: 1000
Switch 4 woudl show: 1100
Etc.
I've figure out how to output to the LCD (thanks to the edsim51 examples) so that my program shows "0000" when run, but I'm not sure how to implement the rest of my code.
I'm not asking how to be spoon fed how to do it but more like I could use some guidance. Would it be possible to use the "switch banks" on the screen to do this? There ARE 8 of them. And do I have to use interrupts to increment and decrement the counters?
If it's of any help here's the code I have written to display "0000" on the LCD:
; 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
Tue Nov 30 2010, 12:51 am
You should start by putting you display code into subroutines.
One to initialise and a second to display the string at 30h
There is no need to use interrupts yet.
Poll (read repeatedly) the 8 buttons in turn,
it will be easiest to wait until a key is pressed and released.
The method is quite simple.
If an up key is pressed, increment the value unless it is already at '9'.
If a down key is pressed, decrement the value unless it is already at '0'.
Every time a key press is found, refresh the display.
Sorry, don't know what they are.
One to initialise and a second to display the string at 30h
There is no need to use interrupts yet.
Poll (read repeatedly) the 8 buttons in turn,
it will be easiest to wait until a key is pressed and released.
The method is quite simple.
If an up key is pressed, increment the value unless it is already at '9'.
If a down key is pressed, decrement the value unless it is already at '0'.
Every time a key press is found, refresh the display.
Would it be possible to use the "switch banks" on the screen to do this?
There ARE 8 of them.Reiniku
Sorry, don't know what they are.
[ Edited Wed Dec 01 2010, 01:20 am ]
Tue Nov 30 2010, 01:06 am
hi Reiniku
can u give more info on ur project
what ur idea
how much u done whats next u want where ur getting problem
need some detail here
can u give more info on ur project
what ur idea
how much u done whats next u want where ur getting problem
need some detail here
Tue Nov 30 2010, 01:24 am
The original idea was proposed as:
"The idea is to display the count on the LCD display. Using switches, a user can increment and decrement a counter. After every press of a switch, the subsequent count can be seen on the LCD display. There are 4 counters that have to be seen on the LCD. Use two switches per one counter: first switch as incrementer, second as decrementer."
So far all I have is the digits displayed on the LCD. I'm very very new at assembly so I'm not really sure how to continue.
I have the code written listed above. I'm fortunate since this is all done on edsim51 to simulate 8051.
"The idea is to display the count on the LCD display. Using switches, a user can increment and decrement a counter. After every press of a switch, the subsequent count can be seen on the LCD display. There are 4 counters that have to be seen on the LCD. Use two switches per one counter: first switch as incrementer, second as decrementer."
So far all I have is the digits displayed on the LCD. I'm very very new at assembly so I'm not really sure how to continue.
I have the code written listed above. I'm fortunate since this is all done on edsim51 to simulate 8051.
Tue Nov 30 2010, 01:36 am
hi Reiniku
ru bound to do it asm if not then why not in c
that is easy as compare to asm
u can use interrupts to counts
increment and decrements
let say to take a start u need an external interrupts
download this book and read its interrupt chapter
ita a mazidi book
1) http://ifile.it/l3t8e4k/The_8051_Microcontroller_and_Embedded_Systems_Using_Assembly_and_C-2nd-ed_BY_Mazidi.rar
or
2) http://ifile.it/l3t8e4k
ru bound to do it asm if not then why not in c
that is easy as compare to asm
u can use interrupts to counts
increment and decrements
let say to take a start u need an external interrupts
download this book and read its interrupt chapter
ita a mazidi book
1) http://ifile.it/l3t8e4k/The_8051_Microcontroller_and_Embedded_Systems_Using_Assembly_and_C-2nd-ed_BY_Mazidi.rar
or
2) http://ifile.it/l3t8e4k
Tue Nov 30 2010, 01:51 am
I'm bound to asm by the project's guidelines to familiarize myself with hardware interaction. I will go and read the chapter as you have suggested.
Tue Nov 30 2010, 10:31 am
Hello! Thank you for the sample code. I am reading through it right now to get an understanding and I am attempting to run it in the edsim51 simulation but it does not recognize "db" as part of its instruction set. Is this abnormal? Sorry for the trouble.
It says:
Syntax Error - DB statement - DB " HELLO WORLD ",0H
when attempting to assemble.
It says:
Syntax Error - DB statement - DB " HELLO WORLD ",0H
when attempting to assemble.
[ Edited Tue Nov 30 2010, 10:33 am ]
Tue Nov 30 2010, 10:41 am
hi Reiniku
oho ur using edsim51
but i make it in keil
why ur not using keil
oho ur using edsim51
but i make it in keil
why ur not using keil
Tue Nov 30 2010, 10:43 am
It's part of the supplied tools given by my intrsuctor with its manual. The whole class is to use edsim51 so we are streamlined and can compare code on our different projects as we progress.
The problem is that we were instructed to use this but not HOW to use it, so I've been lost for quite a bit.
It does recognize db when used in this manner
The problem is that we were instructed to use this but not HOW to use it, so I've been lost for quite a bit.
It does recognize db when used in this manner
LEDcodes: ; | this label points to the start address of the 7-segment code table which is ; | stored in program memory using the DB command below DB 11000000B, 11111001B, 10100100B, 10110000B, 10011001B, 10010010B, 10000010B, 11111000B, 10000000B, 10010000B
[ Edited Tue Nov 30 2010, 10:59 am ]
Powered by e107 Forum System