Hi,
I am trying to interface a serial GPS engine board with the NanoCore MaxC32.
For reference, the GPS unit used in this case is:
UsGlobalSat EM406A
I used a MAX3232 chip to translate the TTL levels used for the GPS to the RS232 levels used by the nanocore.
By default, the GPS operates at 4800 bps, 1 stop bit, no pairity.
I can transmit to the GPS properly. When I send the reset command out on the SCI, the GPS unit LED indicates that it has been reset.
However, I cannot receive the data coming out of the GPS. I can see that there is in fact a signal on the RX pin but the RDRE flag in SCISR1 is never set. The voltage levels seem correct for all the TX and RX pins on both the GPS and micro.
Does anyone know what I could do to troubleshoot this problem?
Here is the code I used to test the GPS:
REGBASE equ $0
RAMBASE equ $3800
INITRM equ $0010 ; RAM Position
INITRG EQU $0011 ; Register position
;SCI Registers
SCIBDH equ $00C8
SCIBDL equ $00C9
SCICR1 equ $00CA
SCICR2 equ $00CB
SCISR1 equ $00CC
SCISR2 equ $00CD
SCIDRH equ $00CE
SCIDRL equ $00CF
;PLL Registers
SYNR equ $34
REFDV equ $35
CRGFLG equ $37
CLKSEL equ $39
PLLCTL equ $3A
COPCTL equ $3c
org $3800
myflag rmb 1
mychar rmb 1
org $8000 ; start of program memory
BadInt ; handle UNexpected interrupts...
rti
startup_code
sei ; Disable interrupts
movb #$00,INITRG ; set registers to $0000
movb #$39,INITRM ; init RAM ($3800 - $3fff)
lds #$3fce ; init stack
cli
bclr CLKSEL, #$80 ; disengage PLL to system
bset PLLCTL, #$40 ; turn on PLL
movb #$2, SYNR ; set PLL multiplier
movb #$0, REFDV ; set PLL divider
nop
nop
brclr CRGFLG,#$08,>*+0 ; while (!(crg.crgflg.bit.lock==1))
bset CLKSEL, #$80 ; engage PLL to system
serial_setup:
;BUSCLK is running at 24MHz, so we'll base all speeds on that.
movb #$01,SCIBDH ; set the SCI baud rate to 9600 bits/sec
movb #$38,SCIBDL ; 9600=24x10^6/(16*156), $9c=156
movb #$0c,SCICR2 ; Turn on the SCI transmitter and receiver
;------------------------------------------------------------------
; User Program
;------------------------------------------------------------------
USER_START:
clr mychar
jsr d_xms
load_command:
ldx #mystr ; load the command string that resets the GPS
next_char:
ldab $00,x
cmpb #$00
beq load_char
tx_wait:
brclr SCISR1,#$80,tx_wait ; wait for the TDRE bit to go high
stab SCIDRL
inx
jsr d_xms
jmp next_char ; go set up for next character
load_char:
brclr SCISR1,#$20,load_char ; wait for the RDRE bit to go high
ldab SCIDRL
stab mychar
jsr d_xms
tx_wait1:
brclr SCISR1,#$80,tx_wait1 ; wait for the TDRE bit to go high
ldab mychar
stab SCIDRL
jsr d_xms
jmp load_char ; go set up for next character
d_xms: ldab #100 ; delay 100 ms
dly1: ldy #6000 ; (6000 = 1ms @ 24,000 cycles)
dly: dey ; 1 cycle
bne dly ; 3 cycles
decb
bne dly1
rts
mystr fcc '$PSRF100,0,4800,8,1,0*0C'
fcb $0d,$0a
;fcc '$PSRF102,4800,8,1,0*12'
;fcb $0d,$0a
fcc '$PSRF103,00,01,00,00*25'
fcb $0d,$0a
fcc '$PSRF101,-2686700,-4304200,3851624,96000,497260,921,12,3*1C'
;fcc '$PSRF101,0,0,0,000,0,0,12,1*15' ;hot start
;fcc '$PSRF101,0,0,0,000,0,0,12,8*1C' ;factory reset
fcb $0d,$0a
Nul fcb $00
; ------------------ VECTOR TABLE --------------------
org $FF8A
fdb BadInt ;$FF8A: VREG LVI
fdb BadInt ;$FF8C: PWM emergency shutdown
fdb BadInt ;$FF8E: PortP
fdb BadInt ;$FF90: Reserved
fdb BadInt ;$FF92: Reserved
fdb BadInt ;$FF94: Reserved
fdb BadInt ;$FF96: Reserved
fdb BadInt ;$FF98: Reserved
fdb BadInt ;$FF9A: Reserved
fdb BadInt ;$FF9C: Reserved
fdb BadInt ;$FF9E: Reserved
fdb BadInt ;$FFA0: Reserved
fdb BadInt ;$FFA2: Reserved
fdb BadInt ;$FFA4: Reserved
fdb BadInt ;$FFA6: Reserved
fdb BadInt ;$FFA8: Reserved
fdb BadInt ;$FFAA: Reserved
fdb BadInt ;$FFAC: Reserved
fdb BadInt ;$FFAE: Reserved
fdb BadInt ;$FFB0: CAN transmit
fdb BadInt ;$FFB2: CAN receive
fdb BadInt ;$FFB4: CAN errors
fdb BadInt ;$FFB6: CAN wake-up
fdb BadInt ;$FFB8: FLASH
fdb BadInt ;$FFBA: Reserved
fdb BadInt ;$FFBC: Reserved
fdb BadInt ;$FFBE: Reserved
fdb BadInt ;$FFC0: Reserved
fdb BadInt ;$FFC2: Reserved
fdb BadInt ;$FFC4: CRG self-clock-mode
fdb BadInt ;$FFC6: CRG PLL Lock
fdb BadInt ;$FFC8: Reserved
fdb BadInt ;$FFCA: Reserved
fdb BadInt ;$FFCC: Reserved
fdb BadInt ;$FFCE: PORTJ
fdb BadInt ;$FFD0: Reserved
fdb BadInt ;$FFD2: ATD
fdb BadInt ;$FFD4: Reserved
fdb BadInt ;$FFD6: SCI Serial System
fdb BadInt ;$FFD8: SPI Serial Transfer Complete
fdb BadInt ;$FFDA: Pulse Accumulator Input Edge
fdb BadInt ;$FFDC: Pulse Accumulator Overflow
fdb BadInt ;$FFDE: Timer Overflow
fdb BadInt ;$FFE0: Standard Timer Channel 7
fdb BadInt ;$FFE2: Standard Timer Channel 6
fdb BadInt ;$FFE4: Standard Timer Channel 5
fdb BadInt ;$FFE6: Standard Timer Channel 4
fdb BadInt ;$FFE8: Standard Timer Channel 3
fdb BadInt ;$FFEA: Standard Timer Channel 2
fdb BadInt ;$FFEC: Standard Timer Channel 1
fdb BadInt ;$FFEE: Standard Timer Channel 0
fdb BadInt ;$FFF0: Real Time Interrupt (RTI)
fdb BadInt ;$FFF2: IRQ (External Pin or Parallel I/O) (IRQ)
fdb BadInt ;$FFF4: XIRQ (Pseudo Non-Maskable Interrupt) (XIRQ)
fdb BadInt ;$FFF6: Software Interrupt (SWI)
fdb BadInt ;$FFF8: Illegal Opcode Trap ()
fdb startup_code ;$FFFA: COP Failure (Reset) ()
fdb BadInt ;$FFFC: Clock Monitor Fail (Reset) ()
fdb startup_code ;$FFFE: /RESET