Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

msp430: how to wait one second in assembly?

$
0
0

New to msp430. I trying to make it buzz a tone through a piezo speaker I have plugged into 1.4. I want it to change pitch a few times but can't figure out to control the duration. How can I make the tone hold for one sec before incrementing?  Here's the code I've written so far. I'm trying to do the increment in a loop. 

 

 

 

#include "msp430.h"                     ; #define controlled include file

        NAME    main                    ; module name

        PUBLIC  main                    ; make the main label vissible
                                        ; outside this module
        ORG     0FFFEh
        DC16    init                    ; set reset vector to 'init' label

        RSEG    CSTACK                  ; pre-declaration of segment
        
        ;define all notes as global constants
        

        
        RSEG    CODE                    ; place program in 'CODE' segment

init:   MOV     #SFE(CSTACK), SP        ; set up stack

main:   NOP                             ; main program
        MOV.W   #WDTPW+WDTHOLD,&WDTCTL  ; Stop watchdog timer
        BIS.B   #LFXT1S_2, &BCSCTL3     ; enable Very Low Frequency Oscillator (VLO)mode
      
        BIC.B   #OFIFG, &IFG1           ; clear flags for IFG1
        BIS.W   #(SCG0+SCG1), SR        ; TURN OFF DCO, AND SMCLK
        BIS.B   #SELM_3, &BCSCTL2       ;SELECT VLO TO SOURCE MCLK
        MOV.W   #CCIE, &TACCTL0         ;
        MOV.W   #40, &TACCR0            ;
        MOV.W   #TASSEL_1+MC_1, &TACTL  ;
        
        BIS.B   #1h, &P1DIR
        BIS.B   #10h, &P1DIR            ; p1.4 ouT
        
;LOOP: 

        MOV.W   &TACCR0+10, &TACCR0        ;NEW PITCH
        jmp    LOOP ; Again   
    
  
                                                       ;DELAY ONE SECOND
        
            
  
       
            
                                         
        BIS.W   #CPUOFF+GIE,SR          ;CPU OFF, INTERRUPTS ENABLED
        JMP LOOP                                  ; jump to current location '$'
    
TA0_ISR: 
        XOR.B   #001h, &P1OUT
        XOR.B   #10h, &P1OUT
                                          ;NEED TO CLEAR FLAG
        RETI
        
        COMMON  INTVEC
        ORG     TIMER0_A0_VECTOR
        DW      TA0_ISR
        
                                        ; (endless loop)
        END


Viewing all articles
Browse latest Browse all 2077

Trending Articles