Reply by Adriano Caye December 12, 20052005-12-12
Hi Matt,

you're welcome. I've rechecked your code, and your sequence of USART 
initialization is not according to the manual yet. USART module enabling 
is one of the last operations to be done, take a closer look in the guide.

As you're using a crystal oscilator, you have to add the algorithm 
described on page 4-12 of the manual, otherwise the DCOCLK will be used. 
I usually follow this sequence in my code:

1 - Initialize clock (page 4-12)
2 - Initialize I/O port registers (chapter 9)
3 - Initialize USART (page 13-4)
4 - Enter the main loop.

And as I said, you must not check the URXIFG0 in the Rx ISR, because it 
will be always off when the ISR is executed. You have to rearrange your 
ISR to take out this flag test.

Regards,
Adriano.


matthewbuza1 wrote:
> Adriano,
> 
> Thank you for your help I cleaned up the code and went back to the 
> guide for some help. I made the changes necessary, but when I hooked 
> up the GPS there was no interrupt. I poked around and my ACLK  is 
> not ocsilating. I have the necessary caps on C1 and C2. I feel that 
> it may due to the ordering of the UART 
> setup. I had read before on another post if certain comments were 
> out of order the UART could be unreliable. I feel I am so close to 
> getting this to work. I've post the cleaned up code below, if anyone 
> has any more suggestions, I would appreciate it. Thank you for the 
> help that I have got so far. Best Regards   - Matt
> 
> 
> #include  <msp430x15x.h>
> 
> 
> ;NMEA, GPS defined Characters.
> 
> 
> 
> #define Cc 43h
> #define Gg 47h
> #define Mm 4Dh
> #define Pp 50h
> #define Rr 52h
> #define comma 2Ch
> #define dollar 24h
> #define star 2Ah
> 
> 
> 
> #define check_sum   R15
> #define trans_val   R14
> #define gpschar     R13
> #define check_sum1  R12
> #define commas      R11
> #define gpsfail     R10
> 
> 
> SAVE      EQU     200h
> 
> 
> 
> ;--------------------------------
> ----------
>             ORG     0C000h                  ; Progam Start
> ;--------------------------------
> ----------
> RESET       mov.w   #0400h,SP               ; Initialize stackpointer
> StopWDT     mov.w   #WDTPW+WDTHOLD,&WDTCTL  ; Stop WDT
> 
> ;page 13-4 of the user guide. Setup USART.
> 
> SetupUART0  bis.b   #SWRST,&UCTL0           ; Set SWRST, set SWRST 
> to 1.                        
>             bis.b   #UTXE0+URXE0,&ME1       ; Enable USART0 
> TXD/RXD             
>             bic.b   #SWRST,&UCTL0           ; Set SWRST
>             bis.b   #URXIE0,&IE1
>             bis.b   #CHAR,&UCTL0            ; 8-bit char
>             ;bis.b   #SSEL1,&UTCTL0          ; UCLK = SMCLK
>             ;mov.b   #0D0h,&UBR00            ; 2MHz 9600
>             ;mov.b   #000h,&UBR10            ;
>             ;mov.b   #000h,&UMCTL0           ; no modulation
>             bis.b   #SSEL0,&UTCTL0          ; UCLK = ACLK
>             mov.b   #006h,&UBR00            ; 32k/4800 - 6.8267
>             mov.b   #000h,&UBR10            ;  
>             mov.b   #06Fh,&UMCTL0           ; modulation
> 
> ;Setup P1 pins, and USART pins.
>    
> SetupP1     bis.b   #00Fh,&P1DIR            ;all P1 pins set to 
> output
>             bic.b   #00Fh,&P1OUT            ;Clear all the p1 pins
> SetupP3     bis.b   #030h,&P3SEL            ; P3.4,5 = USART0 TXD/RXD
>             bis.b   #010h,&P3DIR
> 
> 
> ;looking to output a value to the Transmit pin (33) on micro-
> controller.
> ;hoping to see voltage output from pin. Read by multimeter.
>            
> Mainloop    bis.w   #CPUOFF+GIE,SR          ; Enter LPM0(low power 
> mode), interrupts enabled
>             nop
> 
> ;--------------------------------
> ----------            
> USART0RX_ISR; Starting NMEA command for the GPS.
> ;--------------------------------
> ----------
> 
> ;Begin GPS and look for first Edge detect. Once edge detect is found 
> start main
> ;gps reading loop. URXIFGO flag is set to zero when an interrupt is 
> detected.
> 
> 
> ;Edge was detected
> ;Setting constants
> GPSloop     mov.b   #00h,check_sum1
>             mov.b   #00h,R5
>             mov.b   #00h,commas
> 
> ;Testing to see if the character is in the buffer, 
> URXIFGO=1.            
> 
> edgedet0    bit.b   #URXIFG0,&IFG1        ;TESTING URXIFGx
>             jnz     dllrchar              ;jumps when flag is set to 
> 1, whole character is in the RX Buffer.
>             jmp     edgedet0
> 
> ;capturing the character
> 
> dllrchar    mov.b   &U0RXBUF,gpschar      ;move data from buffer to 
> register
>             cmp.b   #dollar,gpschar       ;compare received data 
> with expected
>             jeq     flagdllr              ;jump to set flag
>             jmp     fin             ;bad data start over
>             
> ;Saving the Character
> 
> flagdllr    mov.b   gpschar,SAVE(R5)      ;saving data
>             inc     R5                    ;increment for next save
>        
> fin          reti
> 
> ;--------------------------------
> ----------
> ;           Interrupt Vectors
> ;--------------------------------
> ----------
>             ORG     0FFFEh                  ;
>             DW      RESET                   ; POR, ext. Reset, 
> Watchdog
>             ORG     0FFF2h                  ;
>             DW      USART0RX_ISR            ; go to edge detect
>             END
>             
>             
>      
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> --- In msp430@msp4..., Adriano Caye <adriano@n...> wrote:
> 
>>Hi Matthew,
>>
>>I'll say some comments about your code:
>>
>>1 - there is a correct sequence to initialize UART registers, and 
> 
> you're 
> 
>>not quite following this sequence. Look at the page 13-4 of the 
> 
> user's 
> 
>>guide.
>>
>>2 - It seems you're not using the DCO as the BRCLK. So, you
don't 
> 
> need 
> 
>>to enable the receive-start edge detect feature.
>>
>>3 - In your GPSREAD function, you have to put a RET instruction in 
> 
> the 
> 
>>end of the subroutine. It's not very good practice though to call 
>>subroutines inside an ISR. It should be as fast as possible, to be 
> 
> able 
> 
>>to receive other characters.
>>
>>4 - You don't have to check for the URXIFG0 bit in the ISR.
It'll 
> 
> be 
> 
>>always off, as the page 13-18 of the user's guide states. When the 
> 
> ISR 
> 
>>is called, that flag is automatically turned off.
>>
>>Regards,
>>Adriano.
>>
>>
>>matthewbuza1 wrote:
>>
>>>I am working to incorporate navman callisto gps with the 
> 
> msp430x15. 
> 
>>>I was new to the entire emmbedded programming until a month ago. 
> 
> So 
> 
>>>I have had to learn the programming and microcontroller pretty 
> 
> fast. 
> 
>>>By no means am I proficient. I have searched and viewed a ton of 
>>>postings via this group. First I am not a student and this is 
> 
> not 
> 
>>>for a class. I have attached my code below. I beleive i've set 
> 
> the 
> 
>>>baud rate correctly, it has to be 4800 for the navman. My 
> 
> question 
> 
>>>is that the URXIFG0 flag in the IFG1 register is setting to 1, 
>>>signifiying an accepted character. I feel i have set up the edge 
>>>detect correctly. In the user manual page 13-19 i followed their 
>>>pattern. Although when the interrupt is sounded and the sub-
> 
> routine 
> 
>>>is called, I loop and wait for the URXIFG0 flag to be triggered 
> 
> to 1 
> 
>>>signifying a character in the RX buffer. Also when i debug, i 
> 
> look 
> 
>>>at the RX address and my character from the gps is never 
> 
> received. 
> 
>>>My programming is simplified down, I am trying to read in the 
> 
> first 
> 
>>>character which is a dollar sign and save in into memory. Any 
> 
> help 
> 
>>>would be greatly appreciated. Thank you. -Matt
>>>
>>>#include  <msp430x15x.h>
>>>
>>>
>>>;NMEA, GPS defined Characters.
>>>
>>>
>>>
>>>#define Cc 43h
>>>#define Gg 47h
>>>#define Mm 4Dh
>>>#define Pp 50h
>>>#define Rr 52h
>>>#define comma 2Ch
>>>#define dollar 24h
>>>#define star 2Ah
>>>
>>>
>>>
>>>#define check_sum   R15
>>>#define trans_val   R14
>>>#define gpschar     R13
>>>#define check_sum1  R12
>>>#define commas      R11
>>>#define gpsfail     R10
>>>
>>>
>>>SAVE      EQU     200h
>>>
>>>
>>>
>>>;----------------------------
> 
> ----
> 
>>>----------
>>>            ORG     0C000h                  ; Progam Start
>>>;----------------------------
> 
> ----
> 
>>>----------
>>>RESET       mov.w   #0A00h,SP               ; Initialize 
> 
> stackpointer
> 
>>>StopWDT     mov.w   #WDTPW+WDTHOLD,&WDTCTL  ; Stop WDT
>>>
>>>SetupUART0  bis.b   #UTXE0+URXE0,&ME1       ; Enable USART0 
> 
> TXD/RXD
> 
>>>            bis.b   #CHAR,&UCTL0            ; 8-bit characters
>>>            mov.b   #SSEL0,&UTCTL0          ; UCLK = ACLK
>>>            mov.b   #006h,&UBR00            ; 32k/4800 - 6.8267
>>>            mov.b   #000h,&UBR10            ;
>>>            mov.b   #077h,&UMCTL0           ; modulation
>>>            bic.b   #SWRST,&UCTL0           ; **Initialize USART

>>>state machine**
>>>            bis.b   #URXIE0,&IE1            ; Enable USART0 RX 
>>>interrupt
>>>SetupP1     bis.b   #00Fh,&P1DIR            ;all P1 pins set to 
>>>output
>>>            bic.b   #00Fh,&P1OUT            ;Clear all the p1 
> 
> pins
> 
>>>SetupP3     bis.b   #030h,&P3SEL            ; P3.4,5 = USART0 
> 
> TXD/RXD
> 
>>>            bis.b   #010h,&P3DIR
>>>
>>>
>>>
>>>            
>>>beginedge   bic.b   #URXSE,&U0TCTL          ;clears edge detect 
> 
> for 
> 
>>>whole program
>>>            bis.b   #URXSE,&U0TCTL          ;re-enable edge 
>>>detect            
>>>R5setup     mov.b   #00h,R5
>>>
>>>
>>>
>>>;looking to output a value to the Transmit pin (33) on micro-
>>>controller.
>>>;hoping to see voltage output from pin. Read by multimeter.
>>>   
>>>   
>>>               
>>>Mainloop    bis.w   #CPUOFF+GIE,SR          ; Enter LPM0(low 
> 
> power 
> 
>>>mode), interrupts enabled
>>>            nop
>>>
>>>
>>>;----------------------------
> 
> ----
> 
>>>----------            
>>>GPSREAD; Starting NMEA command for the GPS.
>>>;----------------------------
> 
> ----
> 
>>>----------
>>>            
>>>            xor.b   #001h,&P1OUT            ;Toggle P1.0, turns 
> 
> on 
> 
>>>GPS via transistor
>>>
>>>GPSloop     mov.b   #00h,check_sum1
>>>            mov.b   #00h,R5
>>>            mov.b   #00h,commas
>>>            jmp     edgedet0
>>>            
>>>            
>>>edgedet0    bit.b   #URXIFG0,&IFG1        ;TESTING URXIFGx
>>>            jnz     dllrchar    
>>>            jmp     edgedet0
>>>dllrchar    mov.b   &U0RXBUF,gpschar      ;move data from buffer

> 
> to 
> 
>>>register
>>>            cmp.b   #dollar,gpschar       ;compare received data 
>>>with expected
>>>            jeq     flagdllr              ;jump to set flag
>>>            jmp     mastercnt             ;bad data start over
>>>flagdllr    mov.b   gpschar,SAVE(R5)      ;saving data
>>>            inc     R5                    ;increment for next 
> 
> save
> 
>>>URXSECLEAR9 bic.b   #URXSE,&U0TCTL        ;clear urxs signal
>>>            bis.b   #URXSE,&U0TCTL        ;re-enable edge detect
>>>
>>>mastercnt   mov.b   #001h,R15
>>>
>>>
>>>;----------------------------
> 
> ----
> 
>>>----------            
>>>USART0RX_ISR; Detects the edge of a gps signal
>>>;----------------------------
> 
> ----
> 
>>>----------
>>>  
>>>
>>>;Begin GPS and look for first Edge detect. Once edge detect is 
> 
> found 
> 
>>>start main
>>>;gps reading loop.  
>>>               
>>>edgedet     bit.b   #URXIFG0,&IFG1        ;TESTING URXIFGx
>>>            jz      URXSECLEAR    
>>>            jmp     calling
>>>            
>>>;RESET EDGE DETECT
>>>
>>>URXSECLEAR  bic.b   #URXSE,&U0TCTL        ;clear urxs signal
>>>            bis.b   #URXSE,&U0TCTL        ;re-enable edge detect
>>>            bic     #SCG0+SCG1,0(SP)      ;ENABLE BRCLK
>>>calling     call    #GPSREAD              ;character is in RX 
> 
> buffer 
> 
>>>go to read and save.
>>>            reti
>>>
>>>;----------------------------
> 
> ----
> 
>>>----------
>>>;           Interrupt Vectors
>>>;----------------------------
> 
> ----
> 
>>>----------
>>>            ORG     0FFFEh                  ;
>>>            DW      RESET                   ; POR, ext. Reset, 
>>>Watchdog
>>>            ORG     0FFF2h                  ;
>>>            DW      USART0RX_ISR            ; go to edge detect
>>>            END
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>.
>>>
>>> 
>>>Yahoo! Groups Links
>>>
>>>
>>>
>>> 
>>>
>>>
>>
> 
> 
> 
> 
> 
> 
> 
> .
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 

Beginning Microcontrollers with the MSP430

Reply by matthewbuza1 December 9, 20052005-12-09
Adriano,

Thank you for your help I cleaned up the code and went back to the 
guide for some help. I made the changes necessary, but when I hooked 
up the GPS there was no interrupt. I poked around and my ACLK  is 
not ocsilating. I have the necessary caps on C1 and C2. I feel that 
it may due to the ordering of the UART 
setup. I had read before on another post if certain comments were 
out of order the UART could be unreliable. I feel I am so close to 
getting this to work. I've post the cleaned up code below, if anyone 
has any more suggestions, I would appreciate it. Thank you for the 
help that I have got so far. Best Regards   - Matt


#include  <msp430x15x.h>


;NMEA, GPS defined Characters.



#define Cc 43h
#define Gg 47h
#define Mm 4Dh
#define Pp 50h
#define Rr 52h
#define comma 2Ch
#define dollar 24h
#define star 2Ah



#define check_sum   R15
#define trans_val   R14
#define gpschar     R13
#define check_sum1  R12
#define commas      R11
#define gpsfail     R10


SAVE      EQU     200h



;--------------------------------
----------
            ORG     0C000h                  ; Progam Start
;--------------------------------
----------
RESET       mov.w   #0400h,SP               ; Initialize stackpointer
StopWDT     mov.w   #WDTPW+WDTHOLD,&WDTCTL  ; Stop WDT

;page 13-4 of the user guide. Setup USART.

SetupUART0  bis.b   #SWRST,&UCTL0           ; Set SWRST, set SWRST 
to 1.                        
            bis.b   #UTXE0+URXE0,&ME1       ; Enable USART0 
TXD/RXD             
            bic.b   #SWRST,&UCTL0           ; Set SWRST
            bis.b   #URXIE0,&IE1
            bis.b   #CHAR,&UCTL0            ; 8-bit char
            ;bis.b   #SSEL1,&UTCTL0          ; UCLK = SMCLK
            ;mov.b   #0D0h,&UBR00            ; 2MHz 9600
            ;mov.b   #000h,&UBR10            ;
            ;mov.b   #000h,&UMCTL0           ; no modulation
            bis.b   #SSEL0,&UTCTL0          ; UCLK = ACLK
            mov.b   #006h,&UBR00            ; 32k/4800 - 6.8267
            mov.b   #000h,&UBR10            ;  
            mov.b   #06Fh,&UMCTL0           ; modulation

;Setup P1 pins, and USART pins.
   
SetupP1     bis.b   #00Fh,&P1DIR            ;all P1 pins set to 
output
            bic.b   #00Fh,&P1OUT            ;Clear all the p1 pins
SetupP3     bis.b   #030h,&P3SEL            ; P3.4,5 = USART0 TXD/RXD
            bis.b   #010h,&P3DIR


;looking to output a value to the Transmit pin (33) on micro-
controller.
;hoping to see voltage output from pin. Read by multimeter.
           
Mainloop    bis.w   #CPUOFF+GIE,SR          ; Enter LPM0(low power 
mode), interrupts enabled
            nop

;--------------------------------
----------            
USART0RX_ISR; Starting NMEA command for the GPS.
;--------------------------------
----------

;Begin GPS and look for first Edge detect. Once edge detect is found 
start main
;gps reading loop. URXIFGO flag is set to zero when an interrupt is 
detected.


;Edge was detected
;Setting constants
GPSloop     mov.b   #00h,check_sum1
            mov.b   #00h,R5
            mov.b   #00h,commas

;Testing to see if the character is in the buffer, 
URXIFGO=1.            

edgedet0    bit.b   #URXIFG0,&IFG1        ;TESTING URXIFGx
            jnz     dllrchar              ;jumps when flag is set to 
1, whole character is in the RX Buffer.
            jmp     edgedet0

;capturing the character

dllrchar    mov.b   &U0RXBUF,gpschar      ;move data from buffer to 
register
            cmp.b   #dollar,gpschar       ;compare received data 
with expected
            jeq     flagdllr              ;jump to set flag
            jmp     fin             ;bad data start over
            
;Saving the Character

flagdllr    mov.b   gpschar,SAVE(R5)      ;saving data
            inc     R5                    ;increment for next save
       
fin          reti

;--------------------------------
----------
;           Interrupt Vectors
;--------------------------------
----------
            ORG     0FFFEh                  ;
            DW      RESET                   ; POR, ext. Reset, 
Watchdog
            ORG     0FFF2h                  ;
            DW      USART0RX_ISR            ; go to edge detect
            END
            
            
     























--- In msp430@msp4..., Adriano Caye <adriano@n...> wrote:
>
> Hi Matthew,
> 
> I'll say some comments about your code:
> 
> 1 - there is a correct sequence to initialize UART registers, and 
you're 
> not quite following this sequence. Look at the
page 13-4 of the 
user's 
> guide.
> 
> 2 - It seems you're not using the DCO as the BRCLK. So, you don't

need 
> to enable the receive-start edge detect feature.
> 
> 3 - In your GPSREAD function, you have to put a RET instruction in 
the 
> end of the subroutine. It's not very good
practice though to call 
> subroutines inside an ISR. It should be as fast as possible, to be 
able 
> to receive other characters.
> 
> 4 - You don't have to check for the URXIFG0 bit in the ISR. It'll

be 
> always off, as the page 13-18 of the user's
guide states. When the 
ISR 
> is called, that flag is automatically turned off.
> 
> Regards,
> Adriano.
> 
> 
> matthewbuza1 wrote:
> > I am working to incorporate navman callisto gps with the 
msp430x15. 
> > I was new to the entire emmbedded programming
until a month ago. 
So 
> > I have had to learn the programming and
microcontroller pretty 
fast. 
> > By no means am I proficient. I have searched
and viewed a ton of 
> > postings via this group. First I am not a student and this is 
not 
> > for a class. I have attached my code below. I
beleive i've set 
the 
> > baud rate correctly, it has to be 4800 for
the navman. My 
question 
> > is that the URXIFG0 flag in the IFG1 register
is setting to 1, 
> > signifiying an accepted character. I feel i have set up the edge 
> > detect correctly. In the user manual page 13-19 i followed their 
> > pattern. Although when the interrupt is sounded and the sub-
routine 
> > is called, I loop and wait for the URXIFG0
flag to be triggered 
to 1 
> > signifying a character in the RX buffer. Also
when i debug, i 
look 
> > at the RX address and my character from the
gps is never 
received. 
> > My programming is simplified down, I am
trying to read in the 
first 
> > character which is a dollar sign and save in
into memory. Any 
help 
> > would be greatly appreciated. Thank you.
-Matt
> > 
> > #include  <msp430x15x.h>
> > 
> > 
> > ;NMEA, GPS defined Characters.
> > 
> > 
> > 
> > #define Cc 43h
> > #define Gg 47h
> > #define Mm 4Dh
> > #define Pp 50h
> > #define Rr 52h
> > #define comma 2Ch
> > #define dollar 24h
> > #define star 2Ah
> > 
> > 
> > 
> > #define check_sum   R15
> > #define trans_val   R14
> > #define gpschar     R13
> > #define check_sum1  R12
> > #define commas      R11
> > #define gpsfail     R10
> > 
> > 
> > SAVE      EQU     200h
> > 
> > 
> > 
> > ;----------------------------
----
> > ----------
> >             ORG     0C000h                  ; Progam Start
> > ;----------------------------
----
> > ----------
> > RESET       mov.w   #0A00h,SP               ; Initialize 
stackpointer
> > StopWDT     mov.w  
#WDTPW+WDTHOLD,&WDTCTL  ; Stop WDT
> > 
> > SetupUART0  bis.b   #UTXE0+URXE0,&ME1       ; Enable USART0 
TXD/RXD
> >             bis.b   #CHAR,&UCTL0         
  ; 8-bit characters
> >             mov.b   #SSEL0,&UTCTL0          ; UCLK = ACLK
> >             mov.b   #006h,&UBR00            ; 32k/4800 - 6.8267
> >             mov.b   #000h,&UBR10            ;
> >             mov.b   #077h,&UMCTL0           ; modulation
> >             bic.b   #SWRST,&UCTL0           ; **Initialize USART 
> > state machine**
> >             bis.b   #URXIE0,&IE1            ; Enable USART0 RX 
> > interrupt
> > SetupP1     bis.b   #00Fh,&P1DIR            ;all P1 pins set to 
> > output
> >             bic.b   #00Fh,&P1OUT            ;Clear all the p1 
pins
> > SetupP3     bis.b   #030h,&P3SEL         
  ; P3.4,5 = USART0 
TXD/RXD
> >             bis.b   #010h,&P3DIR
> > 
> > 
> > 
> >             
> > beginedge   bic.b   #URXSE,&U0TCTL          ;clears edge detect 
for 
> > whole program
> >             bis.b   #URXSE,&U0TCTL          ;re-enable edge 
> > detect            
> > R5setup     mov.b   #00h,R5
> > 
> > 
> > 
> > ;looking to output a value to the Transmit pin (33) on micro-
> > controller.
> > ;hoping to see voltage output from pin. Read by multimeter.
> >    
> >    
> >                
> > Mainloop    bis.w   #CPUOFF+GIE,SR          ; Enter LPM0(low 
power 
> > mode), interrupts enabled
> >             nop
> > 
> > 
> > ;----------------------------
----
> > ----------            
> > GPSREAD; Starting NMEA command for the GPS.
> > ;----------------------------
----
> > ----------
> >             
> >             xor.b   #001h,&P1OUT            ;Toggle P1.0, turns 
on 
> > GPS via transistor
> > 
> > GPSloop     mov.b   #00h,check_sum1
> >             mov.b   #00h,R5
> >             mov.b   #00h,commas
> >             jmp     edgedet0
> >             
> >             
> > edgedet0    bit.b   #URXIFG0,&IFG1        ;TESTING URXIFGx
> >             jnz     dllrchar    
> >             jmp     edgedet0
> > dllrchar    mov.b   &U0RXBUF,gpschar      ;move data from buffer 
to 
> > register
> >             cmp.b   #dollar,gpschar       ;compare received data 
> > with expected
> >             jeq     flagdllr              ;jump to set flag
> >             jmp     mastercnt             ;bad data start over
> > flagdllr    mov.b   gpschar,SAVE(R5)      ;saving data
> >             inc     R5                    ;increment for next 
save
> > URXSECLEAR9 bic.b   #URXSE,&U0TCTL       
;clear urxs signal
> >             bis.b   #URXSE,&U0TCTL        ;re-enable edge detect
> > 
> > mastercnt   mov.b   #001h,R15
> > 
> > 
> > ;----------------------------
----
> > ----------            
> > USART0RX_ISR; Detects the edge of a gps signal
> > ;----------------------------
----
> > ----------
> >   
> > 
> > ;Begin GPS and look for first Edge detect. Once edge detect is 
found 
> > start main
> > ;gps reading loop.  
> >                
> > edgedet     bit.b   #URXIFG0,&IFG1        ;TESTING URXIFGx
> >             jz      URXSECLEAR    
> >             jmp     calling
> >             
> > ;RESET EDGE DETECT
> > 
> > URXSECLEAR  bic.b   #URXSE,&U0TCTL        ;clear urxs signal
> >             bis.b   #URXSE,&U0TCTL        ;re-enable edge detect
> >             bic     #SCG0+SCG1,0(SP)      ;ENABLE BRCLK
> > calling     call    #GPSREAD              ;character is in RX 
buffer 
> > go to read and save.
> >             reti
> > 
> > ;----------------------------
----
> > ----------
> > ;           Interrupt Vectors
> > ;----------------------------
----
> > ----------
> >             ORG     0FFFEh                  ;
> >             DW      RESET                   ; POR, ext. Reset, 
> > Watchdog
> >             ORG     0FFF2h                  ;
> >             DW      USART0RX_ISR            ; go to edge detect
> >             END
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > .
> > 
> >  
> > Yahoo! Groups Links
> > 
> > 
> > 
> >  
> > 
> >
>





Reply by Adriano Caye December 8, 20052005-12-08
Hi Matthew,

I'll say some comments about your code:

1 - there is a correct sequence to initialize UART registers, and you're 
not quite following this sequence. Look at the page 13-4 of the user's 
guide.

2 - It seems you're not using the DCO as the BRCLK. So, you don't need

to enable the receive-start edge detect feature.

3 - In your GPSREAD function, you have to put a RET instruction in the 
end of the subroutine. It's not very good practice though to call 
subroutines inside an ISR. It should be as fast as possible, to be able 
to receive other characters.

4 - You don't have to check for the URXIFG0 bit in the ISR. It'll be 
always off, as the page 13-18 of the user's guide states. When the ISR 
is called, that flag is automatically turned off.

Regards,
Adriano.


matthewbuza1 wrote:
> I am working to incorporate navman callisto gps with the msp430x15. 
> I was new to the entire emmbedded programming until a month ago. So 
> I have had to learn the programming and microcontroller pretty fast. 
> By no means am I proficient. I have searched and viewed a ton of 
> postings via this group. First I am not a student and this is not 
> for a class. I have attached my code below. I beleive i've set the 
> baud rate correctly, it has to be 4800 for the navman. My question 
> is that the URXIFG0 flag in the IFG1 register is setting to 1, 
> signifiying an accepted character. I feel i have set up the edge 
> detect correctly. In the user manual page 13-19 i followed their 
> pattern. Although when the interrupt is sounded and the sub-routine 
> is called, I loop and wait for the URXIFG0 flag to be triggered to 1 
> signifying a character in the RX buffer. Also when i debug, i look 
> at the RX address and my character from the gps is never received. 
> My programming is simplified down, I am trying to read in the first 
> character which is a dollar sign and save in into memory. Any help 
> would be greatly appreciated. Thank you. -Matt
> 
> #include  <msp430x15x.h>
> 
> 
> ;NMEA, GPS defined Characters.
> 
> 
> 
> #define Cc 43h
> #define Gg 47h
> #define Mm 4Dh
> #define Pp 50h
> #define Rr 52h
> #define comma 2Ch
> #define dollar 24h
> #define star 2Ah
> 
> 
> 
> #define check_sum   R15
> #define trans_val   R14
> #define gpschar     R13
> #define check_sum1  R12
> #define commas      R11
> #define gpsfail     R10
> 
> 
> SAVE      EQU     200h
> 
> 
> 
> ;--------------------------------
> ----------
>             ORG     0C000h                  ; Progam Start
> ;--------------------------------
> ----------
> RESET       mov.w   #0A00h,SP               ; Initialize stackpointer
> StopWDT     mov.w   #WDTPW+WDTHOLD,&WDTCTL  ; Stop WDT
> 
> SetupUART0  bis.b   #UTXE0+URXE0,&ME1       ; Enable USART0 TXD/RXD
>             bis.b   #CHAR,&UCTL0            ; 8-bit characters
>             mov.b   #SSEL0,&UTCTL0          ; UCLK = ACLK
>             mov.b   #006h,&UBR00            ; 32k/4800 - 6.8267
>             mov.b   #000h,&UBR10            ;
>             mov.b   #077h,&UMCTL0           ; modulation
>             bic.b   #SWRST,&UCTL0           ; **Initialize USART 
> state machine**
>             bis.b   #URXIE0,&IE1            ; Enable USART0 RX 
> interrupt
> SetupP1     bis.b   #00Fh,&P1DIR            ;all P1 pins set to 
> output
>             bic.b   #00Fh,&P1OUT            ;Clear all the p1 pins
> SetupP3     bis.b   #030h,&P3SEL            ; P3.4,5 = USART0 TXD/RXD
>             bis.b   #010h,&P3DIR
> 
> 
> 
>             
> beginedge   bic.b   #URXSE,&U0TCTL          ;clears edge detect for 
> whole program
>             bis.b   #URXSE,&U0TCTL          ;re-enable edge 
> detect            
> R5setup     mov.b   #00h,R5
> 
> 
> 
> ;looking to output a value to the Transmit pin (33) on micro-
> controller.
> ;hoping to see voltage output from pin. Read by multimeter.
>    
>    
>                
> Mainloop    bis.w   #CPUOFF+GIE,SR          ; Enter LPM0(low power 
> mode), interrupts enabled
>             nop
> 
> 
> ;--------------------------------
> ----------            
> GPSREAD; Starting NMEA command for the GPS.
> ;--------------------------------
> ----------
>             
>             xor.b   #001h,&P1OUT            ;Toggle P1.0, turns on 
> GPS via transistor
> 
> GPSloop     mov.b   #00h,check_sum1
>             mov.b   #00h,R5
>             mov.b   #00h,commas
>             jmp     edgedet0
>             
>             
> edgedet0    bit.b   #URXIFG0,&IFG1        ;TESTING URXIFGx
>             jnz     dllrchar    
>             jmp     edgedet0
> dllrchar    mov.b   &U0RXBUF,gpschar      ;move data from buffer to 
> register
>             cmp.b   #dollar,gpschar       ;compare received data 
> with expected
>             jeq     flagdllr              ;jump to set flag
>             jmp     mastercnt             ;bad data start over
> flagdllr    mov.b   gpschar,SAVE(R5)      ;saving data
>             inc     R5                    ;increment for next save
> URXSECLEAR9 bic.b   #URXSE,&U0TCTL        ;clear urxs signal
>             bis.b   #URXSE,&U0TCTL        ;re-enable edge detect
> 
> mastercnt   mov.b   #001h,R15
> 
> 
> ;--------------------------------
> ----------            
> USART0RX_ISR; Detects the edge of a gps signal
> ;--------------------------------
> ----------
>   
> 
> ;Begin GPS and look for first Edge detect. Once edge detect is found 
> start main
> ;gps reading loop.  
>                
> edgedet     bit.b   #URXIFG0,&IFG1        ;TESTING URXIFGx
>             jz      URXSECLEAR    
>             jmp     calling
>             
> ;RESET EDGE DETECT
> 
> URXSECLEAR  bic.b   #URXSE,&U0TCTL        ;clear urxs signal
>             bis.b   #URXSE,&U0TCTL        ;re-enable edge detect
>             bic     #SCG0+SCG1,0(SP)      ;ENABLE BRCLK
> calling     call    #GPSREAD              ;character is in RX buffer 
> go to read and save.
>             reti
> 
> ;--------------------------------
> ----------
> ;           Interrupt Vectors
> ;--------------------------------
> ----------
>             ORG     0FFFEh                  ;
>             DW      RESET                   ; POR, ext. Reset, 
> Watchdog
>             ORG     0FFF2h                  ;
>             DW      USART0RX_ISR            ; go to edge detect
>             END
> 
> 
> 
> 
> 
> 
> 
> 
> .
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 

Reply by matthewbuza1 December 7, 20052005-12-07
I am working to incorporate navman callisto gps with the msp430x15. 
I was new to the entire emmbedded programming until a month ago. So 
I have had to learn the programming and microcontroller pretty fast. 
By no means am I proficient. I have searched and viewed a ton of 
postings via this group. First I am not a student and this is not 
for a class. I have attached my code below. I beleive i've set the 
baud rate correctly, it has to be 4800 for the navman. My question 
is that the URXIFG0 flag in the IFG1 register is setting to 1, 
signifiying an accepted character. I feel i have set up the edge 
detect correctly. In the user manual page 13-19 i followed their 
pattern. Although when the interrupt is sounded and the sub-routine 
is called, I loop and wait for the URXIFG0 flag to be triggered to 1 
signifying a character in the RX buffer. Also when i debug, i look 
at the RX address and my character from the gps is never received. 
My programming is simplified down, I am trying to read in the first 
character which is a dollar sign and save in into memory. Any help 
would be greatly appreciated. Thank you. -Matt

#include  <msp430x15x.h>


;NMEA, GPS defined Characters.



#define Cc 43h
#define Gg 47h
#define Mm 4Dh
#define Pp 50h
#define Rr 52h
#define comma 2Ch
#define dollar 24h
#define star 2Ah



#define check_sum   R15
#define trans_val   R14
#define gpschar     R13
#define check_sum1  R12
#define commas      R11
#define gpsfail     R10


SAVE      EQU     200h



;--------------------------------
----------
            ORG     0C000h                  ; Progam Start
;--------------------------------
----------
RESET       mov.w   #0A00h,SP               ; Initialize stackpointer
StopWDT     mov.w   #WDTPW+WDTHOLD,&WDTCTL  ; Stop WDT

SetupUART0  bis.b   #UTXE0+URXE0,&ME1       ; Enable USART0 TXD/RXD
            bis.b   #CHAR,&UCTL0            ; 8-bit characters
            mov.b   #SSEL0,&UTCTL0          ; UCLK = ACLK
            mov.b   #006h,&UBR00            ; 32k/4800 - 6.8267
            mov.b   #000h,&UBR10            ;
            mov.b   #077h,&UMCTL0           ; modulation
            bic.b   #SWRST,&UCTL0           ; **Initialize USART 
state machine**
            bis.b   #URXIE0,&IE1            ; Enable USART0 RX 
interrupt
SetupP1     bis.b   #00Fh,&P1DIR            ;all P1 pins set to 
output
            bic.b   #00Fh,&P1OUT            ;Clear all the p1 pins
SetupP3     bis.b   #030h,&P3SEL            ; P3.4,5 = USART0 TXD/RXD
            bis.b   #010h,&P3DIR



            
beginedge   bic.b   #URXSE,&U0TCTL          ;clears edge detect for 
whole program
            bis.b   #URXSE,&U0TCTL          ;re-enable edge 
detect            
R5setup     mov.b   #00h,R5



;looking to output a value to the Transmit pin (33) on micro-
controller.
;hoping to see voltage output from pin. Read by multimeter.
   
   
               
Mainloop    bis.w   #CPUOFF+GIE,SR          ; Enter LPM0(low power 
mode), interrupts enabled
            nop


;--------------------------------
----------            
GPSREAD; Starting NMEA command for the GPS.
;--------------------------------
----------
            
            xor.b   #001h,&P1OUT            ;Toggle P1.0, turns on 
GPS via transistor

GPSloop     mov.b   #00h,check_sum1
            mov.b   #00h,R5
            mov.b   #00h,commas
            jmp     edgedet0
            
            
edgedet0    bit.b   #URXIFG0,&IFG1        ;TESTING URXIFGx
            jnz     dllrchar    
            jmp     edgedet0
dllrchar    mov.b   &U0RXBUF,gpschar      ;move data from buffer to 
register
            cmp.b   #dollar,gpschar       ;compare received data 
with expected
            jeq     flagdllr              ;jump to set flag
            jmp     mastercnt             ;bad data start over
flagdllr    mov.b   gpschar,SAVE(R5)      ;saving data
            inc     R5                    ;increment for next save
URXSECLEAR9 bic.b   #URXSE,&U0TCTL        ;clear urxs signal
            bis.b   #URXSE,&U0TCTL        ;re-enable edge detect

mastercnt   mov.b   #001h,R15


;--------------------------------
----------            
USART0RX_ISR; Detects the edge of a gps signal
;--------------------------------
----------
  

;Begin GPS and look for first Edge detect. Once edge detect is found 
start main
;gps reading loop.  
               
edgedet     bit.b   #URXIFG0,&IFG1        ;TESTING URXIFGx
            jz      URXSECLEAR    
            jmp     calling
            
;RESET EDGE DETECT

URXSECLEAR  bic.b   #URXSE,&U0TCTL        ;clear urxs signal
            bis.b   #URXSE,&U0TCTL        ;re-enable edge detect
            bic     #SCG0+SCG1,0(SP)      ;ENABLE BRCLK
calling     call    #GPSREAD              ;character is in RX buffer 
go to read and save.
            reti

;--------------------------------
----------
;           Interrupt Vectors
;--------------------------------
----------
            ORG     0FFFEh                  ;
            DW      RESET                   ; POR, ext. Reset, 
Watchdog
            ORG     0FFF2h                  ;
            DW      USART0RX_ISR            ; go to edge detect
            END