lab exercises
play

Lab Exercises INEl 4206 Microprocessors Laboratory 1 bis.b - PowerPoint PPT Presentation

Lab Exercises INEl 4206 Microprocessors Laboratory 1 bis.b #1,&P1DIR ; P1.0 as output main: NOP ; main program xor.b #1,&P1OUT ; Toggle P1.0 ; Wait mov #50000,R15 ; Delay to R15 L1: dec R15 ; Decrement


  1. Lab Exercises INEl 4206 Microprocessors

  2. Laboratory 1 bis.b #1,&P1DIR ; P1.0 as output main: NOP ; main program xor.b #1,&P1OUT ; Toggle P1.0 ; Wait mov #50000,R15 ; Delay to R15 L1: dec R15 ; Decrement R15 jnz L1 ; Delay over ? jmp main ; Again nop

  3. Modified Laboratory 1 bis.b #1,&P1DIR ; P1.0 as output main: NOP ; main program ; xor.b #1,&P1OUT ; Toggle P1.0 bic.b #1, &P1OUT ; Wait ;mov #50000,R15 ; Delay to R15 mov tLow, R15 L1: dec R15 ; Decrement R15 jnz L1 ; Delay over ? bis.b #1, &P1OUT mov tHigh, R15 L2; dec R15 jnz L2 jmp main ; Again nop

  4. Laboratory 4 bic.b #00001000b,&P1DIR ; P1.3 as input bis.b #1,&P1DIR ; P1.0 as output main: NOP ; main program ; xor.b #1,&P1OUT ; Toggle P1.0 bic.b #1, &P1OUT ; LED off bis.b #00001000b,&P1REN; select internal res bis.b #00001000b,&P1OUT; make it pull-up POLL bit.b #00001000b, &P1IN ; poll P1.3 jz POLL ; P1.3 service code xor.b #00000001b, &P1OUT jmp POLL nop

  5. Laboratory 5 bic.b #00001000b,&P1SEL ; default bic.b #00001000b,&P1DIR ; P1.3 as input bis.b #1,&P1DIR ; P1.0 as output bic.b #1, &P1OUT ; LED off bis.b #00001000b,&P1REN; select internal res bis.b #00001000b,&P1OUT; make it pull-up bis.b #00001000b,&P1IE ; enable P1.3 interrupt HERE jmp HERE ; P1.3 ISR PBISR bic.b #00001000b,&P1IFG ; clear interrupt flag xor.b #00000001b, &P1OUT ; toggle LED reti ; return from interrupt ; interrupt vectors ORG 0FFFEh ; MSP430 RESET Vector 
 DW RESET ; address of label RESET 
 ORG 0FFE4h ; interrupt vector 2 DW PBISR ; address of label PBISR END

  6. Laboratory 6 (code example) SetupP1 bis.b #001h,&P1DIR ; P1.0 output SetupC0 mov.w #CCIE,&CCTL0 ; CCR0 interrupt enabled mov.w #50000,&CCR0 ; SetupTA mov.w #TASSEL_2+MC_2,&TACTL ; SMCLK, contmode ; Mainloop bis.w #CPUOFF+GIE,SR ; CPU o ff , interrupts enabled nop ; Required only for debugger ;------------------------------------------------------------------------------- TA0_ISR; Toggle P1.0 ;------------------------------------------------------------------------------- xor.b #001h,&P1OUT ; Toggle P1.0 add.w #50000,&CCR0 ; Add O ff set to CCR0 reti ; ; ;------------------------------------------------------------------------------ ; Interrupt Vectors ;------------------------------------------------------------------------------ .sect ".reset" ; MSP430 RESET Vector .short RESET ; .sect ".int09" ; Timer_A0 Vector .short TA0_ISR ;

  7. Modified Laboratory 6 (cont) bis.b #BIT0,&P1DIR ; Set P1.0 to output direction bis.b #BIT0,&P1OUT ; P1.0 high bic.w #LOCKLPM5,&PM5CTL0 ; Unlock I/O pins (FR2433 only) bis.w #CCIE,&TA0CCTL0 ; TACCR0 interrupt enabled mov.w tLow,&TA0CCR0 mov.w tLow, tOffset bis.w #TASSEL__SMCLK|MC__CONTINOUS,&TA0CTL ; SMCLK, continuous mode Mainloop nop bis.w #LPM0+GIE,SR ; Enter LPM0 w/ interrupt nop ; For debugger

  8. Modified Laboratory 6 ;---------------------------------------- TIMER0_A0_ISR; ISR for TA0CCR0 ;----------------------------------------- xor.b #BIT0,&P1OUT ; Toggle LED cmp tLow, tOffset jne tL1 mov tHigh,tOffset ; Add offset to TA0CCR0 jmp tL2 tL1: mov tLow, tOffset tL2: add.w tOffset,&TA0CCR0 ; Add offset to TA0CCR0 reti ;----------------------------------------- ; Interrupt Vectors ;----------------------------------------- .sect RESET_VECTOR ; MSP430 RESET Vector .short RESET .sect TIMER0_A0_VECTOR ; Timer A0 ISR .short TIMER0_A0_ISR

Recommend


More recommend