Hi everybody!, i'm form Argentina and this is my first time posting in the forum...
I'm working on QG8 microcontroller, and i have problems trying communicating with a GPS module (ET-332 of GlobalSat). Specifically, while the program runs and de RX pin is receiving GPS data string, it doesn't enters in the RX interrupt subroutine (
I've verified that RX pin is receiving data from GPS transmitter (@4800 bauds) with a scope.
This is my interrupt subroutine code of the RX in assembler:
sci_rx_isr:
lda SCIS1 ; clear RDRF flag
lda SCID ; clear RDRF flag
mov SCID,X+ ; data vector from GPS
cpx #68 ; string length
bne no_end
ldhx #RMC_string ; start again when 68 bytes string data is complete
no_end:
rti
Also I've verified many times the configuration of the SCI registers, and is OK. The bus frequency is 2.4576 MHz and BR bits value is 32. Here is my initialization code of the SCI module.
mov #$00,SCIBDH ;
mov #$20,SCIBDL ; BR [SBR12:SBR0] = 32
mov #%00000000,SCIC1 ; 8 data bits, no parity bit
; LOOPS = 0 (Normal operation — RxD and TxD use separate pins)
; SCISWAI = 0 (SCI clocks freeze while CPU is in wait mode)
; RSRC = 0 (util solo cuando LOOPS = 1)
; M = 0 (Normal — start + 8 data bits (LSB first) + stop)
; WAKE = 0 (Idle-line wakeup)
; ILT = 0 (Idle character bit count starts after start bit)
; PE = 0 (No hardware parity generation or checking)
; PT = 0 (util solo cuando PE = 1)
mov #%00100100,SCIC2 ; interrupt enabled when RDRF flag = 1, RxD SCI receiver enabled
; TIE = 0 (Hardware interrupts from TDRE disabled (use polling))
; TCIE = 0 (Hardware interrupts from TC disabled (use polling))
; RIE = 1 (Hardware interrupt requested when RDRF flag is 1), se genera interrupción cuando se completa la recepción de un dato en el registro SCID
; ILIE = 0 (Hardware interrupts from IDLE disabled (use polling))
; TE = 0 (Transmitter OFF)
; RE = 1 (Receiver ON)
; RWU = 0 (Normal SCI receiver operation)
; SBK = 0 (Normal transmitter operation)
mov #$00,SCIC3 ; no interrupts generated by errors
Someone can help me??
Thanks!!
已解决! 转到解答。
Hello,
I can see a number of problems with your code -
The following code snippet assumes absolute addressing mode is used.
; Equates:
CODE equ ROMStart
BUFLEN equ 68
RXEND equ 0
; Variables:
ORG Z_RAMStart ; Zero-page RAM
Rxbuf: ds.b BUFLEN
Rxcnt: ds.b 1
flag: ds.b 1 ; Single bit flags
; Start of code:
ORG CODE ; Flash address where code commences
; Other code here
; ISR code:
SCIRX_ISR:
pshh ; Save current value
clrh
ldx Rxcnt ; Current position in buffer
lda SCIS1 ; Preparatory to clearing flag
lda SCID ; Also clears flag
sta Rxbuf,x ; Current byte to buffer
incx
cpx #BUFLEN
bne SRI1 ; Branch if data packet not complete
clrx ; Ready for next packet
bset RXEND,flag ; Set flag
SRI1: stx Rxcnt ; Save current position in buffer
pulh ; Restore prior value
rti
; Other code here
; Vector entries:
ORG Vscirx
dc.w SCIRX_ISR
ORG Vreset
dc.w Main_start ; Start address of main code loop
Regards,
Mac
Hello,
I can see a number of problems with your code -
The following code snippet assumes absolute addressing mode is used.
; Equates:
CODE equ ROMStart
BUFLEN equ 68
RXEND equ 0
; Variables:
ORG Z_RAMStart ; Zero-page RAM
Rxbuf: ds.b BUFLEN
Rxcnt: ds.b 1
flag: ds.b 1 ; Single bit flags
; Start of code:
ORG CODE ; Flash address where code commences
; Other code here
; ISR code:
SCIRX_ISR:
pshh ; Save current value
clrh
ldx Rxcnt ; Current position in buffer
lda SCIS1 ; Preparatory to clearing flag
lda SCID ; Also clears flag
sta Rxbuf,x ; Current byte to buffer
incx
cpx #BUFLEN
bne SRI1 ; Branch if data packet not complete
clrx ; Ready for next packet
bset RXEND,flag ; Set flag
SRI1: stx Rxcnt ; Save current position in buffer
pulh ; Restore prior value
rti
; Other code here
; Vector entries:
ORG Vscirx
dc.w SCIRX_ISR
ORG Vreset
dc.w Main_start ; Start address of main code loop
Regards,
Mac
The first thing that strikes me is that you aren't loading anything into H:X ? Surely you need to set that ?
e.g.
----------------
sci_rx_isr:
lda SCIS1 ; clear RDRF flag
; lda SCID ; clear RDRF flag
ldhx global_u16_address_variable
mov SCID,X+ ; data vector from GPS
cpx #68 ; string length
bne no_end
ldhx #RMC_string ; start again when 68 bytes string data is complete
no_end:
sthx global_u16_address_variable
rti
----------------
I've commented the lda SCID as you are trying to read it twice - each read clears the buffer. I'm assuming that the mov will be valid. If not replace with:
lda SCID
sta ,x
aix #1
Also, your code is going to write to the start of memory - is that what you actually want? You might want a counter and an address that get added together.
Hope that helps
James