PWM variable con MSP430G2553
Saludos!
Acá les traigo un código para obtener un PWM de 25% a 75% solo presionando en P1.3 la salida es en P1.2 y lo visualizamos conectando un osciloscopio a nuestro puerto P1.2 y GND del micro
_________________________________________________________________________________
;-------------------------------------------------------------------------------
; MSP430 Assembler Code Template for use with TI Code Composer Studio
;
;
;-------------------------------------------------------------------------------
.cdecls C,LIST,"msp430.h" ; Include device header file
;-------------------------------------------------------------------------------
.text ; Assemble into program memory
.retain ; Override ELF conditional linking
; and retain current section
.retainrefs ; Additionally retain any sections
; that have references to current
; section
;-------------------------------------------------------------------------------
RESET mov.w #__STACK_END,SP ; Initialize stackpointer
StopWDT mov.w #WDTPW|WDTHOLD,&WDTCTL ; Stop watchdog timer
;-------------------------------------------------------------------------------
; Main loop here
mov.b &CALBC1_1MHZ,&BCSCTL1
mov.b &CALDCO_1MHZ, &DCOCTL
mov.b #04h,&P1DIR
bis.b #08h,&P1REN; activa resistencia
bis.b #08h,&P1OUT ;resistencia PULL UP
bis.b #04h,&P1SEL ; P1.2
;UUUUUUCSIDMCURIF
mov.w #0000001000010100b,&TACTL
mov.w #03E8h,&TACCR0
;CMCCSCSC0COUTCCOCC
mov.w #0000000001100000b, &TACCTL1
primero mov.w #02EEh,&TACCR1 ;75%
;-------------------------------------------------------------------------------
bit.b #08h,&P1IN
jz primero
segunda mov.w #0FAh,&TACCR1 ;25%
bit.b #08h,&P1IN
jnz segunda
jmp primero
;-------------------------------------------------------------------------------
; Stack Pointer definition
;-------------------------------------------------------------------------------
.global __STACK_END
.sect .stack
;-------------------------------------------------------------------------------
; Interrupt Vectors
;-------------------------------------------------------------------------------
.sect ".reset" ; MSP430 RESET Vector
.short RESET
Comentarios
Publicar un comentario