Maxeyas
Junior Member level 3
Re: Programing In Assembly for 8051
I had a mistake its actually clean 5V on pin 2.
I have deleted the 6000h external memory usage. Now just writting stright to P0 and updating LCD accourdingly.
I made the instructions as below:
Hopefully its what you wanted me to do.
The full code looks as below:
Overall the same issues.
Hi,
4.5V is not 5V.
Why is it not 5.0V?
With Pin2 = 4.5V you should have -0.25V at Pin3. According datasheet.
*****
Without scope it will be hard.
Additionally the circuit is so confusing. It is mixing several periferal access methods. This makes it very difficult.
With every access to one periferal you need to take care about the other periferals connected to the multiplexed data_address bus.
Therfore I recommend to get rid of the "MOVX @DPTR" instruction.
(See microcontroller datasheet page167 "External Data Memory Write Access" timing diagram. This all happens with your single MOVX instruction. Especially Port0 first switches to output the lower address bits, then it outputs the data bits... all within this single instruction. And your circuit is not made for this!)
***
(I don´t know your ASM instructions, so I have to tell in words. You have to write the true code.)
configure instructions: (port setup)
* Port0 as input (databus)
* Port2 as output (address select part 1)
* output data 0xE0 to port2 (disable all reads)
* port1.0 as output (ADC_WR_n)
* output HIGH on port1.0 (disable ADC_WR_n)
* port1.2 as output (LCD_RS)
* output LOW on port1.2 (init to LOW)
* port1.3 as output (LCD_EN)
* output LOW on port1.3 (disable LCD_EN)
* port3.6 as output (SRAM_RW)
* output HIGH on port3.6 (SRAM_WR = read)
* port3.7 as output (SRAM_DS)
* output HIGH on port3.7 (disable SRAM_DS)
... then we go the next step
Klaus
I had a mistake its actually clean 5V on pin 2.
I have deleted the 6000h external memory usage. Now just writting stright to P0 and updating LCD accourdingly.
I made the instructions as below:
Code:
mov P0,#0FFh
mov P2,#0E0h
setb P1.0
clr P1.2
clr P1.3
setb P3.6
setb P3.7
The full code looks as below:
Code:
EN EQU P1.3 // Enable Pin
RS EQU P1.2 // Register Select
// Setting P0 as Input
mov P0,#0FFh
mov P2,#0E0h
setb P1.0
clr P1.2
clr P1.3
setb P3.6
setb P3.7
// Setting P2 as Output
lcall Reset
// Insure 8 Bit Mode
mov P0, #38h // Function Set
lcall SendCommand
lcall SendCommand
lcall SendCommand
mov P0, #0Eh // Display Control
lcall SendCommand
mov P0, #06h // Entry mode set
lcall SendCommand
mov P0, #01h // Display Control
lcall SendCommand
mov P0, #'M'
lcall SendData
mov P0, #'A'
lcall SendData
mov P0, #'X'
lcall SendData
sjmp $
SendCommand:
clr RS // Setting 0 in RS (0=commands,1=data)
setb EN // Setting 1 in EN (pulse)
NOP
NOP
NOP
NOP
clr EN // Setting 0 in EN (send pulse)
lcall Delay
ret
SendData:
setb RS // Setting 1 in RS (0=commands,1=data)
setb EN // Setting 1 in EN (pulse)
NOP
NOP
NOP
NOP
clr EN // Setting 0 in EN (send pulse)
lcall Delay
ret
Delay: // 100x5 = 5000us = 5 ms
mov R7, #100
D3: mov R6, #5
djnz R6,$
djnz R7,D3
ret
Reset: // 160x250 = 40000us = 40 ms
mov R7, #160
D4: mov R6, #250
djnz R6,$
djnz R7,D4
ret
end
Overall the same issues.