Zetta08 wrote:
I am using the QD2 and I have problems with the ADCThe instructions for Init_ADC init code are:LDA #$18
STA SPMSC1
LDA #$F0
STA ADCCFG
MOV #$01,ADCSC1 ; Commence conversion Ch 1
LDA #$02 ; Select Ch 1 for analog operation
STA APCTL1In de Loop:BSET ADCSC1_ADCH1,ADCSC1
; Abort conversion & commence new conversion Ch 3WAIT:
TST ADCSC1BPL WAIT ; Loop until conversion complete
LDA ADCRL........................But ADCRL it is always $00
Hello Mac
For that say that
BSET ADCSC1_ADCH1,ADCSC1 ;it begins a new conversion in the channel CH3
In the Loop I use the following instructions but it always jumps to HAB_DISPARO
This means that ADCRL is always > #$64 (Not #$00, sorry)
LDA ADCRL
CMP #$64
BHS HAB_DISPARO
INH_DISPARO BSET F_NIVEL,CONDICION
BRA FIN_CICLO
HAB_DISPARO BCLR F_NIVEL,CONDICION
..............................
Thank you and regards
Zetta08
Hello Zetta08,
I might have expected that your intent was to measure channel 1, rather than channel 3. As you have not selected analog operation for channel 3 (APCTL1 register), it is possible that this input may have its digital pullup enabled, which may account for your observations.
I suggest that you don't use the BSET instruction for initiating a conversion - simultaneously write to all bits of the ADCSC1 register to reduce the confusion over what bits are already set.
MOV #$01,ADCSC1 ; Commence conversion Ch 1
or
MOV #$03,ADCSC1 ; Commence conversion Ch 3
Regards,
Mac
Finally I found the solution.
It is necessary to disable the PTA1 before beginning the conversion.
In my case the correct instructions are:
Common initialization of the write once registers
LDA #$F0
STA ADCCFG
; ADCCFG: ADLPC=1,ADIV1=1,ADIV0=1,ADLSMP=1,MODE1=0,MODE0=0,ADICLK1=0,ADICLK0=0
In de loop:
LDA #$02 ; Disable the Port PTA1 as I/O
STA APCTL1
MOV #$01,ADCSC1 ; It begins the convertion
; Or: BSET ADCSC1_ADCH1,ADCSC1
WAIT TST ADCSC1 ; Waits to that finishes the conversion
BPL WAIT
LDA ADCRL
. . . . . . . . . . .
It works correctly
Thanks to all and greetings