Hello, Im making an application with a HCS08QG8, and the code runs ok, but the broblem is this: when I connect the circuit to power, the display LCD (16x2) Im using dont show the proper message (only the first row with the full squares it normally does when you power it without sending data) and it stays in this way, if I reset the uC it stays the same way (reset enabled), only works sometimes when I repeatedly power on and off, and sometimes when I move the uC directly in the circuit (it has a base so it isnt directly welded, to program and test). Once it starts to run it works well, if I reset it starts to work again, BUT if I power off and on again (without moving the uC) it doesn´t work again. I hope someone can help me.
This is the initialization code:
MCU_init:
; ### MC9S08QG8_8 "Cpu" init code ...
LDA #$FC ; PTB0 y PTB1 como entradas (sensores de freno y liquido respec.)
CLR PTBD ; PTB2=0,PTB3=0,PTB4,..PTB7=0
STA PTBDD ; RS, EN, D0,..,D3 =SALIDA
LDA #$10 ; PTA0, PTA1, PTA2, PTA3 y PTA5 como entradas
CLR PTAD ; PTA4 como salida (activacion de sensores de reversa)
STA PTADD ; PTA0 = entrada sen. reversa, PTA1 = entrada de selector de reversa (555)
; PTA3 y PTA2 son selectores de MODO1/2
MOV #0,PTAD
LDHX #$4000000/(16*9600)
STHX SCIBDH
MOV #$0C,SCIC2
; Common initialization of the write once registers
; SOPT1: COPE=0,COPT=1,STOPE=0,BKGDPE=1,RSTPE=1
LDA #$51 ;#$D1 ;#$53
STA SOPT1
; SPMSC1: LVDF=0,LVDACK=0,LVDIE=0,LVDRE=1,LVDSE=1,LVDE=1,BGBE=0
LDA #$1C
STA SPMSC1
; SPMSC2: PDF=0,PPDF=0,PPDACK=0,PDC=0,PPDC=0
CLRA
STA SPMSC2
; SPMSC3: LVDV=0,LVWV=0
LDA SPMSC3
AND #$CF
STA SPMSC3
; System clock initialization
; ICSTRM: Initialize internal clock trim from a non volatile memory
LDA $FFAF
STA ICSTRM
; ICSSC: Initialize internal clock trim from a non volatile memory
LDA $FFAE
STA ICSSC
; ICSC1: CLKS=0,RDIV=0,IREFS=1,IRCLKEN=0,IREFSTEN=0
MOV #$04,ICSC1 ; Initialization of the ICS control register 1
; ICSC2: BDIV=1,RANGE=0,HGO=0,LP=0,EREFS=0,ERCLKEN=0,EREFSTEN=0
MOV #$40,ICSC2 ; Initialization of the ICS control register 2
; Common initialization of the CPU registers
; PTASE: PTASE5=1,PTASE4=1,PTASE3=1,PTASE2=1,PTASE1=1,PTASE0=1
LDA PTASE
ORA #$3F
STA PTASE
; PTBSE: PTBSE7=1,PTBSE6=1,PTBSE5=1,PTBSE4=1,PTBSE3=1,PTBSE2=1,PTBSE1=1,PTBSE0=1
LDA #$FF
STA PTBSE
; PTADS: PTADS5=0,PTADS4=0,PTADS3=0,PTADS2=0,PTADS1=0,PTADS0=0
CLRA
STA PTADS
; PTBDS: PTBDS7=0,PTBDS6=0,PTBDS5=0,PTBDS4=0,PTBDS3=0,PTBDS2=0,PTBDS1=0,PTBDS0=0
CLRA
STA PTBDS
; CLI ; Enable interrupts
RTS
Hi,
it seems you have an LCD with a KS0066 driver. Is it correct?
You have to wait more than 30 msec after the Vdd rise to 4.5V.
Check the datasheet. Timing is very important with the KS0066.
Bye Jack
It sounds like you have inadequate/wrong delays in your LCD initialization code (which you could have posted instead, since the problem is LCD related).
By the way, the baud initialization is certainly incorrect because of the unneeded hex symbol.
LDHX #$4000000/(16*9600)
Maybe you have a similar typing error in your [LCD] delays, which would throw them off.