Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/16/01 13:26
Read: times


 
#11622 - need help getting started
Hi good people

I am very new in programming. I have read the tutorials on the 8051 and 8052.
I have printed them and studied them and use them now for back-up.
But still I have difficulties which I find even hard to explain.
I get the feeling I am blind for the overall logic of programming.

When reading the tutorials I find no starting point at all that makes any sense.

I'll try to explain.
I have built my own training board, something I wanted to do for a long time.
On the board I have a 80C31 with a 11.0592MHz xtal, of course the old 74HC573 address/data latch, a GAL22V10, An UPD 71054 (8255 but cheaper) and several latches (573) and input buffers (541) to expand IO.
Also there's a DALLAS DS1232 watchdog toggled by a 74HC109 (mapped at 3FF0)
The other half of the 109 is used to enable the tri-state pin of the output-
latches and has a set and reset address on the GAL22V10.
The board runs smoothly and some things I already activated and written to.
So there are no hardware problems.

I need to make use of a timer to toggle the 74HC109. I wrote the timer
interrupt routine for timer0 and it works although it puzzles me how.
I want to attach an LCD 4x20 and a matrix-keyboard and lots of stuff
just to fool around and get into it. The board is prepared to connect the
LCD to the output-latches or the P1 and partially the P3 port or to the PPI.
I have made a keyboard having a complete asci and numeric pad.
So it's a rather flexible thing.

For weeks I am trying to get some logic in the program but I'm getting tired and not improving very much.
If anyone could help me getting started and get me out of this puzzle I would
be very gratefull. In return I would offer assistance (if desired) in designing hardware. I have a professional CAD program to do that and have more than 10 years of experience with it.

Here is what I wrote:

;$MOD51
$TITLE(SMP6.asm)
ORG 0
TCOUNT EQU 40h ; counter adress in internal ram
LCDEN BIT P3.2 ;enable pin
LCDRW BIT P3.3 ;read/write
LCDRS BIT P3.4 ;register select
LCDDATA EQU P1 ;if LCD connected to P1 via JP1

ORG 0Bh ; Timer 0 overflow interrupt.
JMP WDled ;

;enable the outputs of U7 & U8 (latches HC573).

;set enable high (off) not used yet.

; MOV DPL,#0F0h ;low byte flip/flop set adres
; MOV DPH,#3Eh ;high byte
; MOVX @DPTR,A ;write to flip/flop (must be a set to disable)

;set enable low (on)
PUSH PSW
PUSH ACC
PUSH DPL
PUSH DPH
MOV DPL,#0F0h ;low byte flip/flop reset adres
MOV DPH,#3Ch ;high byte (totaal = 3CF0h)
MOVX @DPTR,A ;write to flip/flop (must be a reset to enable)
POP DPH
POP DPL
POP ACC
POP PSW

; Initialisation timer0
MOV TMOD,#01h ; timer0 in 16bit mode
SETB TR0 ; timer on
SETB ET0 ; enable timer interrupt
SETB EA ; enable global interrupts

main:

MOV TH0,#0F0h ; load high byte timer F0
MOV TL0,#00h ; load low byte timer 00

DJNZ TCOUNT,exit_WDled ; if TCOUNT is not 00 go to exit_ WDled
WDled: PUSH PSW
PUSH ACC
PUSH DPL ; store DPTR
PUSH DPH ;
MOV DPL,#0F0h ;low byte flip/flop adres
MOV DPH,#3Fh ;high byte
MOVX @DPTR,A ;write to flip/flop
MOV TCOUNT,#14h ;Set TCOUNT to 14
POP DPH
POP DPL
POP ACC
POP PSW
RETI
exit_WDled:

LCD_init:
PSUH PSW
PUSH DPL
PUSH DPH
MOV DPL,#0E0h ;low byte U7-address
MOV DPH,#3Ch ;high byte U7-address
MOV A,#7Dh ;write 01111100 to accu (RS=0,RW=0,EN=1)
;(BCKL=on aux=high and LED is on)
MOVX @DPTR,A ;write accu to U7
MOV DPL,#0D0h ;low byte U8-address
MOV DPH,#3Ch ;high byte U8-address
MOV A,#01h ;write 00000001 to accu (Clear LCD and home cursor)
MOVX @DPTR,A ;write accu to U8


write_LCD: MOV DPL,#0E0h ;low byte U7-address
MOV DPH,#3Ch ;high byte U7-address
MOV A,#78h ;write 01111000 to accu (RS=0,RW=0,EN=0)
;(BCKL=on aux=high and LED is on)
NOP ;1,64mS
NOP ;
NOP ;
NOP ;
NOP ;1,64mS

MOV DPL,#0E0h ;low byte U7-address
MOV DPH,#3Ch ;high byte U7-address
MOV A,#7Dh ;write 01111100 to accu (RS=0,RW=0,EN=1)
;(BCKL=on aux=high and LED is on)
Home_CRSR:

MOV DPL,#0E0h ;low byte U7-address
MOV DPH,#3Ch ;high byte U7-address
MOV A,#7Dh ;write 01111100 to accu (RS=0,RW=0,EN=1)
;(BCKL=on aux=high and LED is on)

MOV DPL,#0D0h ;low byte U8-address
MOV DPH,#3Ch ;high byte U8-address
MOV A,#02h ;write 0000001x to accu (home and original)
MOVX @DPTR,A ;write accu to U8

MOV DPL,#0E0h ;low byte U7-address
MOV DPH,#3Ch ;high byte U7-address
MOV A,#78h ;write 01111000 to accu (RS=0,RW=0,EN=0)
;(BCKL=on aux=high and LED is on)
NOP ;1,64mS
NOP ;
NOP ;
NOP ;
NOP ;1,64mS

POP DPH
POP DPL
POP PSW
end



List of 8 messages in thread
TopicAuthorDate
need help getting started            01/01/70 00:00      
RE: need help getting started            01/01/70 00:00      
RE: need help getting started            01/01/70 00:00      
RE: need help getting started            01/01/70 00:00      
RE: need help getting started            01/01/70 00:00      
RE: need help getting started            01/01/70 00:00      
RE: need help getting started            01/01/70 00:00      
RE: need help getting started            01/01/70 00:00      

Back to Subject List