Created
March 16, 2013 21:34
-
-
Save titouanc/5178420 to your computer and use it in GitHub Desktop.
Résultat du workshop MSP430 @ UrLab
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;Arbitrary values (aka constants) | |
| #define MIN #0x0008 | |
| #define MAX #0x00ff | |
| #define START #0x00ff | |
| #define True #0x01 | |
| #define False #0x00 | |
| ;Named registers (aka variables) | |
| #define GoUp R13 | |
| #define Thres R14 | |
| #define Cur R15 | |
| .include "msp430g2x31.inc" | |
| org 0xf800 | |
| Setup: | |
| mov.w #0280h,SP ;Init stack pointer | |
| mov.w #WDTPW+WDTHOLD,&WDTCTL ;Init Watchdog | |
| bis.b #0x41, &P1DIR ;Init output pins | |
| mov.w MIN , Thres ;Setting current htreshold to max value | |
| mov.w True, GoUp ;Breathe go up first | |
| Loop: ;Main program loop | |
| and.w True, GoUp | |
| jz DecrementThres | |
| inc.w Thres | |
| cmp.w MAX, Thres | |
| jne LoopInsert | |
| mov.w False, GoUp | |
| LoopInsert: ;Return point for conditionnal branches | |
| mov.w START, Cur | |
| mov.b True, &P1OUT | |
| LoopPWM: ;PWM main code | |
| dec.w Cur | |
| jz Loop | |
| cmp.w Thres, Cur | |
| jge LoopPWM | |
| mov.b False, &P1OUT | |
| jmp LoopPWM | |
| DecrementThres: | |
| dec.w Thres | |
| cmp.w MIN, Thres | |
| jne LoopInsert | |
| mov.w True, GoUp | |
| jmp LoopInsert | |
| org 0xfffe | |
| dw Setup | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment