Jump to content

alanaxis

Members
  • Content Count

    5
  • Joined

  • Last visited

  1. thanks, i took the loop out just to make sure i could create a tone change. I feel like if I can get it to change once, then looping it afterwards shouldn't be that difficult. #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 DelayOneSecond: ; define branch target mov.w #10000, R10 Cont: nop dec R10 ; br #FreqUp ; branch to freq if r10>10k 12kopsinasec jnz Cont ; branch to delay ret 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 ; ; mov.w #10000, R10 ;prep counter BIS.B #1h, &P1DIR BIS.B #10h, &P1DIR ; p1.4 ouT call #DelayOneSecond MOV.W #80, &TACCR0 ;NEW PITCH call #DelayOneSecond jmp $ ; Again ;DELAY ONE SECOND BIS.W #CPUOFF+GIE,SR ;CPU OFF, INTERRUPTS ENABLED JMP $ ; 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
  2. thanks, I've been trying to do a second loop and can't seem to get it to work properly. I think the second timer option may be a bit outside my scope until i get a few more weeks of tinkering in.
  3. 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
  4. Thanks, that all looks a bit advanced for where i'm at(i'm only a few weeks into this). If I can use tones to play happy birthday, then i'll be happy. Maybe something similar to opening a music box or a Christmas card and having it play a simple tone based melody. -David
  5. I'm new to the msp430 and I want to make it play a song through a speaker when I push the button. However, I want to do this with assembly code and not in C. I am using IAR embedded workbench to do my programming. I'm connecting a speaker directly to the msp430 at p1.3 and ground. Are there any tutorials on how to do this? Or any assembly code I could look at that does something similar? I looked through the forum topics but could not find anything that matched with what I'm trying. thanks, alanaxis
×
×
  • Create New...