first commit
This commit is contained in:
BIN
ALL_LAB_ARCHIVE_NOV_04.zip
Normal file
BIN
ALL_LAB_ARCHIVE_NOV_04.zip
Normal file
Binary file not shown.
BIN
ALL_LAB_ARCHIVE_NOV_11.zip
Normal file
BIN
ALL_LAB_ARCHIVE_NOV_11.zip
Normal file
Binary file not shown.
BIN
ALL_LAB_ARCHIVE_OCT20.zip
Normal file
BIN
ALL_LAB_ARCHIVE_OCT20.zip
Normal file
Binary file not shown.
BIN
ARCHIVE_12_1.zip
Normal file
BIN
ARCHIVE_12_1.zip
Normal file
Binary file not shown.
BIN
All Labs.zip
Normal file
BIN
All Labs.zip
Normal file
Binary file not shown.
BIN
FULL_BACKUP_11_18.zip
Normal file
BIN
FULL_BACKUP_11_18.zip
Normal file
Binary file not shown.
BIN
FULL_BACKUP_12_2.zip
Normal file
BIN
FULL_BACKUP_12_2.zip
Normal file
Binary file not shown.
BIN
Lab 01.zip
Normal file
BIN
Lab 01.zip
Normal file
Binary file not shown.
BIN
Lab 01/Lab01.docx
Normal file
BIN
Lab 01/Lab01.docx
Normal file
Binary file not shown.
BIN
Lab 01/Lab01.zip
Normal file
BIN
Lab 01/Lab01.zip
Normal file
Binary file not shown.
BIN
Lab 02/Lab02.docx
Normal file
BIN
Lab 02/Lab02.docx
Normal file
Binary file not shown.
BIN
Lab 02/Lab02.zip
Normal file
BIN
Lab 02/Lab02.zip
Normal file
Binary file not shown.
BIN
Lab 03/cjn_Lab3.docx
Normal file
BIN
Lab 03/cjn_Lab3.docx
Normal file
Binary file not shown.
BIN
Lab 03/cjn_Lab3_Archive.zip
Normal file
BIN
Lab 03/cjn_Lab3_Archive.zip
Normal file
Binary file not shown.
BIN
Lab 04/Lab 4.docx
Normal file
BIN
Lab 04/Lab 4.docx
Normal file
Binary file not shown.
BIN
Lab 04/cjn_Lab4.zip
Normal file
BIN
Lab 04/cjn_Lab4.zip
Normal file
Binary file not shown.
BIN
Lab 06/TechMemo Template.docx
Normal file
BIN
Lab 06/TechMemo Template.docx
Normal file
Binary file not shown.
BIN
Lab 06/cjn_Lab6.docx
Normal file
BIN
Lab 06/cjn_Lab6.docx
Normal file
Binary file not shown.
BIN
Lab 06/cjn_Lab6.zip
Normal file
BIN
Lab 06/cjn_Lab6.zip
Normal file
Binary file not shown.
BIN
Lab 07/Lab07.docx
Normal file
BIN
Lab 07/Lab07.docx
Normal file
Binary file not shown.
BIN
Lab 07/Lab07.zip
Normal file
BIN
Lab 07/Lab07.zip
Normal file
Binary file not shown.
BIN
Lab 09/cjn_Lab09.docx
Normal file
BIN
Lab 09/cjn_Lab09.docx
Normal file
Binary file not shown.
BIN
Lab 09/cjn_Lab09.xlsx
Normal file
BIN
Lab 09/cjn_Lab09.xlsx
Normal file
Binary file not shown.
BIN
Lab 09/cjn_Lab09.zip
Normal file
BIN
Lab 09/cjn_Lab09.zip
Normal file
Binary file not shown.
BIN
Partial Backup LAB8.zip
Normal file
BIN
Partial Backup LAB8.zip
Normal file
Binary file not shown.
BIN
Partial Backup.zip
Normal file
BIN
Partial Backup.zip
Normal file
Binary file not shown.
BIN
Report.docx
Normal file
BIN
Report.docx
Normal file
Binary file not shown.
BIN
Report.pdf
Normal file
BIN
Report.pdf
Normal file
Binary file not shown.
BIN
cjn_Lab1.zip
Normal file
BIN
cjn_Lab1.zip
Normal file
Binary file not shown.
BIN
cjn_Lab10.zip
Normal file
BIN
cjn_Lab10.zip
Normal file
Binary file not shown.
BIN
cjn_Lab11.zip
Normal file
BIN
cjn_Lab11.zip
Normal file
Binary file not shown.
BIN
cjn_Lab11_a1.zip
Normal file
BIN
cjn_Lab11_a1.zip
Normal file
Binary file not shown.
BIN
cjn_Lab12_c1.zip
Normal file
BIN
cjn_Lab12_c1.zip
Normal file
Binary file not shown.
BIN
cjn_Lab2.zip
Normal file
BIN
cjn_Lab2.zip
Normal file
Binary file not shown.
BIN
cjn_Lab3.zip
Normal file
BIN
cjn_Lab3.zip
Normal file
Binary file not shown.
BIN
cjn_Lab4.zip
Normal file
BIN
cjn_Lab4.zip
Normal file
Binary file not shown.
BIN
cjn_Lab5.zip
Normal file
BIN
cjn_Lab5.zip
Normal file
Binary file not shown.
BIN
cjn_Lab6.zip
Normal file
BIN
cjn_Lab6.zip
Normal file
Binary file not shown.
BIN
cjn_Lab7.zip
Normal file
BIN
cjn_Lab7.zip
Normal file
Binary file not shown.
BIN
cjn_Lab8.zip
Normal file
BIN
cjn_Lab8.zip
Normal file
Binary file not shown.
BIN
cjn_Lab9.zip
Normal file
BIN
cjn_Lab9.zip
Normal file
Binary file not shown.
BIN
content/AssLangTools-v4p1-slau131g.pdf
Normal file
BIN
content/AssLangTools-v4p1-slau131g.pdf
Normal file
Binary file not shown.
BIN
content/Blink your first LED - Texas Instruments Wiki.pdf
Normal file
BIN
content/Blink your first LED - Texas Instruments Wiki.pdf
Normal file
Binary file not shown.
2282
content/CapTouchOverview.pdf
Normal file
2282
content/CapTouchOverview.pdf
Normal file
File diff suppressed because one or more lines are too long
BIN
content/EEEE-420-Lab1.pdf
Normal file
BIN
content/EEEE-420-Lab1.pdf
Normal file
Binary file not shown.
BIN
content/EEEE-420-Lab10.pdf
Normal file
BIN
content/EEEE-420-Lab10.pdf
Normal file
Binary file not shown.
BIN
content/EEEE-420-Lab11.pdf
Normal file
BIN
content/EEEE-420-Lab11.pdf
Normal file
Binary file not shown.
BIN
content/EEEE-420-Lab12.pdf
Normal file
BIN
content/EEEE-420-Lab12.pdf
Normal file
Binary file not shown.
BIN
content/EEEE-420-Lab2.pdf
Normal file
BIN
content/EEEE-420-Lab2.pdf
Normal file
Binary file not shown.
BIN
content/EEEE-420-Lab3.pdf
Normal file
BIN
content/EEEE-420-Lab3.pdf
Normal file
Binary file not shown.
BIN
content/EEEE-420-Lab4.pdf
Normal file
BIN
content/EEEE-420-Lab4.pdf
Normal file
Binary file not shown.
BIN
content/EEEE-420-Lab5.pdf
Normal file
BIN
content/EEEE-420-Lab5.pdf
Normal file
Binary file not shown.
BIN
content/EEEE-420-Lab6.pdf
Normal file
BIN
content/EEEE-420-Lab6.pdf
Normal file
Binary file not shown.
BIN
content/EEEE-420-Lab7.pdf
Normal file
BIN
content/EEEE-420-Lab7.pdf
Normal file
Binary file not shown.
BIN
content/EEEE-420-Lab8.pdf
Normal file
BIN
content/EEEE-420-Lab8.pdf
Normal file
Binary file not shown.
BIN
content/EEEE-420-Lab9.pdf
Normal file
BIN
content/EEEE-420-Lab9.pdf
Normal file
Binary file not shown.
BIN
content/How to Call Assembly Subroutines from C..pdf
Normal file
BIN
content/How to Call Assembly Subroutines from C..pdf
Normal file
Binary file not shown.
BIN
content/Importing Projects into CCS - Texas Instruments Wiki.pdf
Normal file
BIN
content/Importing Projects into CCS - Texas Instruments Wiki.pdf
Normal file
Binary file not shown.
Binary file not shown.
164
content/cab_Lab11_hello_world.asm
Normal file
164
content/cab_Lab11_hello_world.asm
Normal file
@@ -0,0 +1,164 @@
|
||||
;-------------------------------------------------------------------------------
|
||||
; MSP430 Assembler Code Template for use with TI Code Composer Studio
|
||||
;******************************************************************************
|
||||
; MSP430G2553 Demo - USI-UART, 9600 Echo ISR, ~1 MHz SMCLK
|
||||
;
|
||||
; Description: Print "hello , world" over and over
|
||||
; Default SMCLK = DCOCLK ~= 1.05 MHz
|
||||
; Baud rate divider with SMCLK @9600 = 1MHz/2400 = 104.15
|
||||
; Original functionality by M. Buccini / G. Morton
|
||||
; Texas Instruments Inc., May 2005
|
||||
; Built with Code Composer Essentials Version: 1.0
|
||||
; Adapted for DB365 by Dorin Patru 05/14/08; updated May 2011
|
||||
; Upgraded for LaunchPad and CCS 5.4 by Dorin Patru December 2013
|
||||
;******************************************************************************
|
||||
.cdecls C,LIST,"msp430g2553.h" ; Include device header file
|
||||
;-------------------------------------------------------------------------------
|
||||
.bss TAFLAG,1 ; TA SW FLG
|
||||
|
||||
|
||||
.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
|
||||
;-------------------------------------------------------------------------------
|
||||
; Setup P1.2 as TXD and P1.1 as RXD; see data sheet port schematic and UG
|
||||
;-------------------------------------------------------------------------------
|
||||
SetupP1 bis.b #6h,&P1SEL ; P1.2/P1.1 = USART0 TXD/RXD
|
||||
bis.b #6h,&P1SEL2 ; P1.2/P1.1 = USART0 TXD/RXD
|
||||
;-------------------------------------------------------------------------------
|
||||
; Setup USI in UART mode, minimal configuration, point to point
|
||||
;-------------------------------------------------------------------------------
|
||||
SetupUART0 clr.b &UCA0CTL0 ; default values - see UG
|
||||
clr.b &UCA0CTL1 ; default values - see UG
|
||||
bis.b #UCSSEL1 + UCSSEL0,&UCA0CTL1 ; UCLK = SMCLK ~1 MHz
|
||||
clr.b &UCA0STAT ; default values - see UG
|
||||
;bis.b #UCLISTEN,&UCA0STAT ; loopback - used for debugging only
|
||||
;-------------------------------------------------------------------------------
|
||||
; For a baud rate of 9600,the pre-scaler value is
|
||||
; = (UCAxBR0 + UCAxBR1 <20> 256) = 104 in decimal - integer part - see UG
|
||||
;-------------------------------------------------------------------------------
|
||||
mov.b #050h,&UCA0BR0 ; Baud Rate = ?
|
||||
mov.b #000h,&UCA0BR1 ; UCBRx = ?
|
||||
;-------------------------------------------------------------------------------
|
||||
; Modulation Control Register - fractional part - see UG
|
||||
;-------------------------------------------------------------------------------
|
||||
mov.b #002h,&UCA0MCTL ; UCBRFx = 0, UCBRSx = 1, UCOS16 = 0
|
||||
;-------------------------------------------------------------------------------
|
||||
; SW reset of the USI state machine
|
||||
;-------------------------------------------------------------------------------
|
||||
bic.b #UCSWRST,&UCA0CTL1 ; **Initialize USI state machine**
|
||||
bis.b #UCA0RXIE,&IE2 ; Enable USART0 RX interrupt
|
||||
bis.b #GIE,SR ; General Interrupts Enabled
|
||||
;-------------------------------------------------------------------------------
|
||||
; After the state machine is reset, the TXD line seems to oscillate a few times
|
||||
; It is therefore safer to check if the machine is in a state in which it is
|
||||
; ready to transmit the next byte. I learned it the hard way ;-(
|
||||
;-------------------------------------------------------------------------------
|
||||
TX2 bit.b #UCA0TXIFG,&IFG2 ; USI TX buffer ready?
|
||||
jz TX2 ; Jump if TX buffer not ready
|
||||
mov.b #0x55,&UCA0TXBUF ; TX <U> charac. eq. to #0x55 in ASCII
|
||||
|
||||
|
||||
|
||||
|
||||
; Setup TimerA to generate an interrupt a few times per second
|
||||
mov #TASSEL1+ID1+ID0+TACLR,&TACTL; SMCLK, /8, STOP mode, clear
|
||||
bic #TAIFG, &TACTL
|
||||
mov #0xFFFF,&TACCR0 ; Load count-up-to value
|
||||
mov #CCIE,&TACCTL0 ; compare, enable compare interrupt
|
||||
|
||||
clr.b &TAFLAG ; Clear TA SW flag
|
||||
|
||||
|
||||
;-------------------------------------------------------------------------------
|
||||
; Main loop from here
|
||||
;-------------------------------------------------------------------------------
|
||||
Mainloop eint ; Enable general interrupts
|
||||
clrz ; Clear Z
|
||||
clr.b &TAFLAG ; Clear TA SW FLAG
|
||||
bis #MC_1,&TACTL ; Start counter in UP MODE
|
||||
ChkTAFlag tst.b &TAFLAG ; Check to see if TA_ISR was
|
||||
jz ChkTAFlag ; executed
|
||||
dint ; Disable general interrupts
|
||||
bic #MC_1+MC_0,&TACTL ; Stop counter
|
||||
call #MyStrCpy
|
||||
nop ;
|
||||
jmp Mainloop ;
|
||||
|
||||
;-----------------------------------------------------------------------
|
||||
; Copy source string starting in R14 to output buffer
|
||||
; No checks for overlap , space in destination , unterminated source ...
|
||||
MyStrCpy:
|
||||
clr R13 ; will count 13 characters of the string
|
||||
mov.w #SourceStr,R14 ; Load address of source
|
||||
|
||||
CopyTest:
|
||||
|
||||
mov.b @R14+,&UCA0TXBUF ; [2 words , 5 cycles] copy src -> dst
|
||||
;wait for buffer empty
|
||||
TXempty: BIT.B #UCA0TXIFG, &IFG2 ; USCI_A0 Transmit Interrupt?
|
||||
jz TXempty
|
||||
inc R13
|
||||
cmp.b #15,R13 ; [2 words , 4 cycles] test source
|
||||
jne CopyTest ; [1 word , 2 cycles] continue if not \0
|
||||
ret ; Yes: return to caller
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Echo back RXed character, confirm TX buffer is ready first
|
||||
;------------------------------------------------------------------------------
|
||||
USART0RX_ISR: nop ;
|
||||
TX1 bit.b #UCA0TXIFG,&IFG2 ; USI TX buffer ready?
|
||||
jz TX1 ; Jump if TX buffer not ready
|
||||
;-------------------------------------------------------------------------------
|
||||
; The order of execution of the two instruction sequence above and the one
|
||||
; below could be switched.
|
||||
;-------------------------------------------------------------------------------
|
||||
mov.b &UCA0RXBUF,r10 ; Move received byte in r10
|
||||
;-------------------------------------------------------------------------------
|
||||
; For demonstration purposes, it is assumed that the remote terminal sends
|
||||
; numbers which are eual to the upper case letter. By adding the value 0x20 to
|
||||
; it, the echoed number represents the same, but lower case letter.
|
||||
;-------------------------------------------------------------------------------
|
||||
add.b #0x20, r10 ; add 0x20 to change upper -> lower case
|
||||
mov.b r10,&UCA0TXBUF ; TX -> RXed character
|
||||
reti ;
|
||||
|
||||
TA_ISR:
|
||||
nop ;
|
||||
bic.w #CCIFG, &TACCTL0 ; clear interrupt flag
|
||||
mov.b #0x01, &TAFLAG ; Set the TA SW flag
|
||||
reti
|
||||
|
||||
; Segment for constant data in ROM
|
||||
SourceStr: ; string constant, stored between 0xC000 and 0xFFFF
|
||||
.string "hello , world! " ; "" should cause a '\0' to be appended
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
;-------------------------------------------------------------------------------
|
||||
; Stack Pointer definition
|
||||
;-------------------------------------------------------------------------------
|
||||
.global __STACK_END
|
||||
.sect .stack
|
||||
;-----------------------------------------------------------------------
|
||||
|
||||
;-------------------------------------------------------------------------------
|
||||
; Interrupt Vectors - see device specific header file
|
||||
;-------------------------------------------------------------------------------
|
||||
.sect ".reset" ; RESET Vector
|
||||
.short RESET
|
||||
.sect ".int07" ; USI - RXD Vector
|
||||
isr_USART: .short USART0RX_ISR ; USI receive ISR
|
||||
.sect ".int09" ; TA0 Vector
|
||||
isr_TA: .short TA_ISR ;
|
||||
.end
|
||||
39
content/cab_Lab9_interrupt_example.c
Normal file
39
content/cab_Lab9_interrupt_example.c
Normal file
@@ -0,0 +1,39 @@
|
||||
#include <msp430g2553.h>
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* main.c
|
||||
*/
|
||||
|
||||
|
||||
int main(void) {
|
||||
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
|
||||
|
||||
// MUST SETUP INTERRUPTS HERE
|
||||
|
||||
while(1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#pragma vector = TIMER0_A0_VECTOR
|
||||
__interrupt void TA_FFF2_ISR(void) {
|
||||
// Timer FFF2 ISR CODE HERE
|
||||
// Only CCIE on CCR0 block generates an interrupt at this vector
|
||||
return;
|
||||
}
|
||||
|
||||
#pragma vector = TIMER0_A1_VECTOR
|
||||
__interrupt void TA_FFF0_ISR(void) {
|
||||
// Timer FFF0 ISR CODE HERE
|
||||
// Three sources (TAIE, CCIE on CCR1 and CCIE on CCR2) all generate interrupts at this vector
|
||||
return;
|
||||
}
|
||||
|
||||
#pragma vector=ADC10_VECTOR
|
||||
__interrupt void ADC10_ISR(void) {
|
||||
// ADC10 ISR CODE HERE
|
||||
return;
|
||||
}
|
||||
16
content/cab_c_and_asm_a1.asm
Normal file
16
content/cab_c_and_asm_a1.asm
Normal file
@@ -0,0 +1,16 @@
|
||||
; assembly comment
|
||||
.cdecls C, LIST, "msp430g2553.h" ;include device header file
|
||||
.text
|
||||
|
||||
.global asm_mult
|
||||
.global second_add
|
||||
|
||||
|
||||
asm_mult:
|
||||
add R13, R12
|
||||
add second_add, R12
|
||||
;mov #1, R14
|
||||
;mov #2, R15
|
||||
ret
|
||||
|
||||
.end
|
||||
24
content/cab_c_and_asm_c1.c
Normal file
24
content/cab_c_and_asm_c1.c
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <msp430g2553.h>
|
||||
//#include "asm_mult.asm"
|
||||
|
||||
// C comment
|
||||
|
||||
int result;
|
||||
|
||||
int second_add;
|
||||
|
||||
extern int asm_mult(int, int);
|
||||
|
||||
void main(void) {
|
||||
//int result;
|
||||
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
|
||||
|
||||
second_add = 4;
|
||||
result = asm_mult(2, 3);
|
||||
//asm(" mov #0x01, R15 ; ");
|
||||
result++;
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
101
content/dxp_Lab11_a1.asm
Normal file
101
content/dxp_Lab11_a1.asm
Normal file
@@ -0,0 +1,101 @@
|
||||
;-------------------------------------------------------------------------------
|
||||
; MSP430 Assembler Code Template for use with TI Code Composer Studio
|
||||
;******************************************************************************
|
||||
; MSP430G2553 Demo - USI-UART, 9600 Echo ISR, ~1 MHz SMCLK
|
||||
;
|
||||
; Description: Echo a received character, RX ISR used.
|
||||
; USI_RX interrupt triggers TX Echo.
|
||||
; Default SMCLK = DCOCLK ~= 1.05 MHz
|
||||
; Baud rate divider with SMCLK @9600 = 1MHz/2400 = 104.15
|
||||
; Original functionality by M. Buccini / G. Morton
|
||||
; Texas Instruments Inc., May 2005
|
||||
; Built with Code Composer Essentials Version: 1.0
|
||||
; Adapted for DB365 by Dorin Patru 05/14/08; updated May 2011
|
||||
; Upgraded for LaunchPad and CCS 5.4 by Dorin Patru December 2013
|
||||
;******************************************************************************
|
||||
.cdecls C,LIST,"msp430g2553.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
|
||||
;-------------------------------------------------------------------------------
|
||||
; Setup P1.2 as TXD and P1.1 as RXD; see data sheet port schematic and UG
|
||||
;-------------------------------------------------------------------------------
|
||||
SetupP1 bis.b #6h,&P1SEL ; P1.2/P1.1 = USART0 TXD/RXD
|
||||
bis.b #6h,&P1SEL2 ; P1.2/P1.1 = USART0 TXD/RXD
|
||||
;-------------------------------------------------------------------------------
|
||||
; Setup USI in UART mode, minimal configuration, point to point
|
||||
;-------------------------------------------------------------------------------
|
||||
SetupUART0 clr.b &UCA0CTL0 ; default values - see UG
|
||||
clr.b &UCA0CTL1 ; default values - see UG
|
||||
bis.b #UCSSEL1 + UCSSEL0,&UCA0CTL1 ; UCLK = SMCLK ~1 MHz
|
||||
clr.b &UCA0STAT ; default values - see UG
|
||||
bis.b #UCLISTEN,&UCA0STAT ; loopback - used for debugging only
|
||||
;-------------------------------------------------------------------------------
|
||||
; For a baud rate of 9600,the pre-scaler value is
|
||||
; = (UCAxBR0 + UCAxBR1 <20> 256) = 104 in decimal - integer part - see UG
|
||||
;-------------------------------------------------------------------------------
|
||||
mov.b #050h,&UCA0BR0 ; Baud Rate = ? - YOU MUST COME UP WITH THIS VALUE
|
||||
mov.b #000h,&UCA0BR1 ; UCBRx = ? - FOR THE REQUIRED BAUD RATE
|
||||
;-------------------------------------------------------------------------------
|
||||
; Modulation Control Register - fractional part - see UG
|
||||
;-------------------------------------------------------------------------------
|
||||
mov.b #002h,&UCA0MCTL ; UCBRFx = 0, UCBRSx = 1, UCOS16 = 0
|
||||
;-------------------------------------------------------------------------------
|
||||
; SW reset of the USI state machine
|
||||
;-------------------------------------------------------------------------------
|
||||
bic.b #UCSWRST,&UCA0CTL1 ; **Initialize USI state machine**
|
||||
bis.b #UCA0RXIE,&IE2 ; Enable USART0 RX interrupt
|
||||
bis.b #GIE,SR ; General Interrupts Enabled
|
||||
;-------------------------------------------------------------------------------
|
||||
; After the state machine is reset, the TXD line seems to oscillate a few times
|
||||
; It is therefore safer to check if the machine is in a state in which it is
|
||||
; ready to transmit the next byte. I learned it the hard way ;-(
|
||||
;-------------------------------------------------------------------------------
|
||||
TX2 bit.b #UCA0TXIFG,&IFG2 ; USI TX buffer ready?
|
||||
jz TX2 ; Jump if TX buffer not ready
|
||||
mov.b #0x55,&UCA0TXBUF ; TX <U> charac. eq. to #0x55 in ASCII
|
||||
;-------------------------------------------------------------------------------
|
||||
; Mainloop starts here:
|
||||
;------------------------------------------------------------------------------- ;
|
||||
Mainloop nop ;
|
||||
nop ; Required for debugger
|
||||
jmp Mainloop ;
|
||||
;------------------------------------------------------------------------------
|
||||
; Echo back RXed character, confirm TX buffer is ready first
|
||||
;------------------------------------------------------------------------------
|
||||
USART0RX_ISR: nop ;
|
||||
TX1 bit.b #UCA0TXIFG,&IFG2 ; USI TX buffer ready?
|
||||
jz TX1 ; Jump if TX buffer not ready
|
||||
;-------------------------------------------------------------------------------
|
||||
; The order of execution of the two instruction sequence above and the one
|
||||
; below could be switched.
|
||||
;-------------------------------------------------------------------------------
|
||||
mov.b &UCA0RXBUF,r10 ; Move received byte in r10
|
||||
;-------------------------------------------------------------------------------
|
||||
; For demonstration purposes, it is assumed that the remote terminal sends
|
||||
; numbers which are eual to the upper case letter. By adding the value 0x20 to
|
||||
; it, the echoed number represents the same, but lower case letter.
|
||||
;-------------------------------------------------------------------------------
|
||||
add.b #0x20, r10 ; add 0x20 to change upper -> lower case
|
||||
mov.b r10,&UCA0TXBUF ; TX -> RXed character
|
||||
reti ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; Stack Pointer definition
|
||||
;-------------------------------------------------------------------------------
|
||||
.global __STACK_END
|
||||
.sect .stack
|
||||
;-------------------------------------------------------------------------------
|
||||
; Interrupt Vectors - see device specific header file
|
||||
;-------------------------------------------------------------------------------
|
||||
.sect ".reset" ; RESET Vector
|
||||
.short RESET
|
||||
.sect ".int07" ; USI - RXD Vector
|
||||
isr_USART: .short USART0RX_ISR ; USI receive ISR
|
||||
.end
|
||||
62
content/dxp_Lab2_a1.asm
Normal file
62
content/dxp_Lab2_a1.asm
Normal file
@@ -0,0 +1,62 @@
|
||||
;-------------------------------------------------------------------------------
|
||||
; MSP430 Assembler Code Template for use with TI Code Composer Studio
|
||||
; MSP430G2553 Demo - Software Toggle P1.0
|
||||
;
|
||||
; Description; Toggle P1.0 by xor'ing P1.0 inside of a software loop.
|
||||
; ACLK = n/a, MCLK = SMCLK = default DCO ~ 800k
|
||||
;
|
||||
; MSP430x1xx
|
||||
; -----------------
|
||||
; /|\| XIN|-
|
||||
; | | |
|
||||
; --|RST XOUT|-
|
||||
; | |
|
||||
; | P1.0|-->LED
|
||||
;
|
||||
; M.Buccini
|
||||
; Texas Instruments, Inc
|
||||
; September 2004
|
||||
; Built with CCE for MSP430 Version: 1.00
|
||||
; Modified and enhanced for the EE365 Kit by Dorin Patru, March 2011;
|
||||
; Modified and enhanced for the LaunchPad by Dorin Patru, September 2013
|
||||
;-------------------------------------------------------------------------------
|
||||
.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
|
||||
;-------------------------------------------------------------------------------
|
||||
SetupP4 bis.b #001h,&P1DIR ; P1.0 output
|
||||
mov.w #0x12EF,r12 ;
|
||||
clr.w r13 ;
|
||||
clr.w r14 ;
|
||||
clr.w r15 ;
|
||||
mov.b r12,r13 ;
|
||||
mov.w r12,r14 ;
|
||||
mov.w r12,r15 ;
|
||||
Mainloop xor.b #001h,&P1OUT ; Toggle P1.0
|
||||
Wait mov.w #050000,R15 ; Delay to R15
|
||||
L1 dec.w R15 ; Decrement R15
|
||||
jnz L1 ; Delay over?
|
||||
jmp Mainloop ; Again
|
||||
;-------------------------------------------------------------------------------
|
||||
; Stack Pointer definition
|
||||
;-------------------------------------------------------------------------------
|
||||
.global __STACK_END
|
||||
.sect .stack
|
||||
|
||||
;-------------------------------------------------------------------------------
|
||||
; Interrupt Vectors
|
||||
;-------------------------------------------------------------------------------
|
||||
.sect ".reset" ; MSP430 RESET Vector
|
||||
.short RESET
|
||||
41
content/dxp_Lab2_c1.c
Normal file
41
content/dxp_Lab2_c1.c
Normal file
@@ -0,0 +1,41 @@
|
||||
//******************************************************************************
|
||||
// MSP430x1xx Demo - Software Toggle P1.0
|
||||
//
|
||||
// Description; Toggle P1.0 by xor'ing P1.0 inside of a software loop.
|
||||
// ACLK = n/a, MCLK = SMCLK = default DCO
|
||||
//
|
||||
// MSP430x1xx
|
||||
// -----------------
|
||||
// /|\| XIN|-
|
||||
// | | |
|
||||
// --|RST XOUT|-
|
||||
// | |
|
||||
// | P1.0|-->LED
|
||||
//
|
||||
// A. Dannenberg
|
||||
// Texas Instruments, Inc
|
||||
// January 2006
|
||||
// Built with CCE for MSP430 Version: 3.0, 4.2
|
||||
// Modified and enhanced by D. Patru for the EE365 MSP430 Kit - March 2011
|
||||
// Modified and enhanced by D. Patru for the LaunchPad Kit - September 2013
|
||||
// Currently built with CCS 5.4.
|
||||
//******************************************************************************
|
||||
|
||||
#include "msp430g2553.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
|
||||
P1DIR |= 0x01; // Set P1.0 to output direction
|
||||
|
||||
for (;;)
|
||||
{
|
||||
volatile unsigned int i; // volatile to prevent optimization
|
||||
|
||||
P1OUT ^= 0x01; // Toggle P1.0 using exclusive-OR
|
||||
|
||||
i = 10000; // SW Delay
|
||||
do i--;
|
||||
while (i != 0);
|
||||
}
|
||||
}
|
||||
101
content/dxp_Lab3_ArrayFill_a2.asm
Normal file
101
content/dxp_Lab3_ArrayFill_a2.asm
Normal file
@@ -0,0 +1,101 @@
|
||||
;-------------------------------------------------------------------------------
|
||||
; MSP430 Assembler Code Template for use with TI Code Composer Studio
|
||||
; Lab3_ArrayFill_a2.asm
|
||||
;
|
||||
; Description; Initialize and fill a 16 element array
|
||||
;
|
||||
; Notes: The specific storage mapping between sections and the address
|
||||
; space can be found in the lnk_msp430f149.cmd file
|
||||
;
|
||||
; D. Phillips, 365_20053; RIT ; 25Mar06 ; Built with CCE for MSP430 V.1.00
|
||||
;
|
||||
; Updated for CCS v4 by Dorin Patru 03/20/11
|
||||
; Updated for CCS v5.4 by Dorin Patru 09/19/13
|
||||
;*******************************************************************************
|
||||
; Labels used as constants by the assembler
|
||||
;-------------------------------------------------------------------------------
|
||||
NUMROWS .equ 0x04
|
||||
NUMCOLS .equ 0x04
|
||||
FULL .equ 0x10
|
||||
;-------------------------------------------------------------------------------
|
||||
.cdecls C,LIST,"msp430g2553.h" ; Include device header file
|
||||
;-------------------------------------------------------------------------------
|
||||
; Uninitialized volatile storage
|
||||
;-------------------------------------------------------------------------------
|
||||
Array: .bss ROW0,4 ; A 16 element 1-D array that can also
|
||||
.bss ROW1,4 ; be considered as a 4x4 2-D array
|
||||
.bss ROW2,4 ; .bss is an assembler directive to indicate where
|
||||
.bss ROW3,4 ; to allocate uninitialized space in memory
|
||||
; The first location is at 0x200
|
||||
.bss SUM,2 ; a sixteen bit storage location
|
||||
;-------------------------------------------------------------------------------
|
||||
; Initialized volatile storage
|
||||
;-------------------------------------------------------------------------------
|
||||
; Constants
|
||||
;-------------------------------------------------------------------------------
|
||||
Constants: .sect ".const" ; designate which section to store these constants
|
||||
|
||||
Zeroes: .byte 0x00 ;
|
||||
Ones: .byte 0xff ;
|
||||
Odds: .byte 0x55 ;
|
||||
Evens: .byte 0xaa ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; Code
|
||||
;-------------------------------------------------------------------------------
|
||||
.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
|
||||
;-------------------------------------------------------------------------------
|
||||
Mainloop:
|
||||
clr r4 ; row counter
|
||||
clr r5 ; column counter
|
||||
clr r6 ; array index
|
||||
clr &SUM ; clear the accumulator location
|
||||
InitLoop: ;
|
||||
cmp.b #FULL, r6 ; passed end of array?
|
||||
jeq DoubleLoop ; yep, done initializing
|
||||
mov.b &Ones, Array(r6); initialize an element of the array
|
||||
add.b #1, r6 ; point to the next location
|
||||
jmp InitLoop ; go again
|
||||
DoubleLoop: ;
|
||||
clr r6 ; clear the array index
|
||||
ROWLOOP: ; outer loop, process a row at a time
|
||||
cmp.b #NUMROWS, r4 ; finished last row?
|
||||
jeq FINI ; yep, done
|
||||
COLLOOP: ; inner loop,
|
||||
cmp.b #NUMCOLS, r5 ; finished last column?
|
||||
jeq NEXTROW ; yep, done, get the nextrow
|
||||
mov.b r6, ROW0(r6) ; store the array index in the array
|
||||
add r6, SUM ; update the summation of the array index
|
||||
add.b #1, r5 ; move to the next element in the row
|
||||
add.b #1, r6 ; update the array index
|
||||
jmp COLLOOP ; try another column
|
||||
NEXTROW: ;
|
||||
clr.b r5 ; clear the column counter
|
||||
add.b #1, r4 ; update the row counter
|
||||
jmp ROWLOOP ; try another row
|
||||
FINI: ;
|
||||
jmp Mainloop ; start over
|
||||
;-------------------------------------------------------------------------------
|
||||
; Stack Pointer definition
|
||||
;-------------------------------------------------------------------------------
|
||||
.global __STACK_END
|
||||
.sect .stack
|
||||
;-------------------------------------------------------------------------------
|
||||
; Interrupt Vectors
|
||||
;-------------------------------------------------------------------------------
|
||||
; This stores away the address of where to jump to when the MCU is reset
|
||||
; (Take a look at the linker command file to find the specific address
|
||||
; associated with the section .reset)
|
||||
;-------------------------------------------------------------------------------
|
||||
.sect ".reset" ; MSP430 RESET Vector
|
||||
.short RESET
|
||||
48
content/dxp_Lab3_ArrayFill_c1.c
Normal file
48
content/dxp_Lab3_ArrayFill_c1.c
Normal file
@@ -0,0 +1,48 @@
|
||||
//******************************************************************************
|
||||
// Lab3_ArrayFill.c
|
||||
//
|
||||
// Description; Initialize and fill a 16 element array
|
||||
//
|
||||
// Assembly version by:
|
||||
// D. Phillips, 365_20053; RIT ; 25Mar06 ; Built with CCE for MSP430 V.1.00
|
||||
// Updated for CCS v4 by Dorin Patru 03/20/11
|
||||
//
|
||||
// C version by: Dorin Patru for the EE365 MSP430 Kit - March 2011
|
||||
// C version updated by: Dorin Patru for the LaunchPad Kit - September 2013
|
||||
//******************************************************************************
|
||||
|
||||
#include "msp430g2553.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
|
||||
//------------------------------------------------------------------------------
|
||||
//char type is one byte; int type is two bytes; volatile to prevent optimization
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
volatile unsigned int i=0, j=0, sum=0; // sum is the sum of the indices
|
||||
volatile unsigned int ArrayFill [4][4];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Initialize ArrayFill to 0xff
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
for (i=0; i<=3; i++)
|
||||
for (j=0; j<=3; j++)
|
||||
ArrayFill[i][j] = 0xff;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
// Fill ArrayFill with the indices values and calculate the sum of the indices
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
for (i=0; i<=3; i++)
|
||||
{
|
||||
for (j=0; j<=3; j++)
|
||||
{
|
||||
ArrayFill[i][j] = (4 * i) + j ;
|
||||
sum = sum + ((4 * i) + j) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
sum = sum;
|
||||
}
|
||||
101
content/dxp_Lab4_ArrayFill_a1.asm
Normal file
101
content/dxp_Lab4_ArrayFill_a1.asm
Normal file
@@ -0,0 +1,101 @@
|
||||
;-------------------------------------------------------------------------------
|
||||
; MSP430 Assembler Code Template for use with TI Code Composer Studio
|
||||
; Lab4_ArrayFill_a1.asm
|
||||
;
|
||||
; Description; Initialize and fill a 16 element array
|
||||
;
|
||||
; Notes: The specific storage mapping between sections and the address
|
||||
; space can be found in the lnk_msp430f149.cmd file
|
||||
;
|
||||
; D. Phillips, 365_20053; RIT ; 25Mar06 ; Built with CCE for MSP430 V.1.00
|
||||
;
|
||||
; Updated for CCS v4 by Dorin Patru 03/20/11
|
||||
; Updated for CCS v5.4 by Dorin Patru 09/19/13
|
||||
;*******************************************************************************
|
||||
; Labels used as constants by the assembler
|
||||
;-------------------------------------------------------------------------------
|
||||
NUMROWS .equ 0x04
|
||||
NUMCOLS .equ 0x04
|
||||
FULL .equ 0x10
|
||||
;-------------------------------------------------------------------------------
|
||||
.cdecls C,LIST,"msp430g2553.h" ; Include device header file
|
||||
;-------------------------------------------------------------------------------
|
||||
; Uninitialized volatile storage
|
||||
;-------------------------------------------------------------------------------
|
||||
Array: .bss ROW0,4 ; A 16 element 1-D array that can also
|
||||
.bss ROW1,4 ; be considered as a 4x4 2-D array
|
||||
.bss ROW2,4 ; .bss is an assembler directive to indicate where
|
||||
.bss ROW3,4 ; to allocate uninitialized space in memory
|
||||
; The first location is at 0x200
|
||||
.bss SUM,2 ; a sixteen bit storage location
|
||||
;-------------------------------------------------------------------------------
|
||||
; Initialized volatile storage
|
||||
;-------------------------------------------------------------------------------
|
||||
; Constants
|
||||
;-------------------------------------------------------------------------------
|
||||
Constants: .sect ".const" ; designate which section to store these constants
|
||||
|
||||
Zeroes: .byte 0x00 ;
|
||||
Ones: .byte 0xff ;
|
||||
Odds: .byte 0x55 ;
|
||||
Evens: .byte 0xaa ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; Code
|
||||
;-------------------------------------------------------------------------------
|
||||
.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
|
||||
;-------------------------------------------------------------------------------
|
||||
Mainloop:
|
||||
clr r4 ; row counter
|
||||
clr r5 ; column counter
|
||||
clr r6 ; array index
|
||||
clr &SUM ; clear the accumulator location
|
||||
InitLoop: ;
|
||||
cmp.b #FULL, r6 ; passed end of array?
|
||||
jeq DoubleLoop ; yep, done initializing
|
||||
mov.b &Ones, Array(r6); initialize an element of the array
|
||||
add.b #1, r6 ; point to the next location
|
||||
jmp InitLoop ; go again
|
||||
DoubleLoop: ;
|
||||
clr r6 ; clear the array index
|
||||
ROWLOOP: ; outer loop, process a row at a time
|
||||
cmp.b #NUMROWS, r4 ; finished last row?
|
||||
jeq FINI ; yep, done
|
||||
COLLOOP: ; inner loop,
|
||||
cmp.b #NUMCOLS, r5 ; finished last column?
|
||||
jeq NEXTROW ; yep, done, get the nextrow
|
||||
mov.b r6, ROW0(r6) ; store the array index in the array
|
||||
add r6, SUM ; update the summation of the array index
|
||||
add.b #1, r5 ; move to the next element in the row
|
||||
add.b #1, r6 ; update the array index
|
||||
jmp COLLOOP ; try another column
|
||||
NEXTROW: ;
|
||||
clr.b r5 ; clear the column counter
|
||||
add.b #1, r4 ; update the row counter
|
||||
jmp ROWLOOP ; try another row
|
||||
FINI: ;
|
||||
jmp Mainloop ; start over
|
||||
;-------------------------------------------------------------------------------
|
||||
; Stack Pointer definition
|
||||
;-------------------------------------------------------------------------------
|
||||
.global __STACK_END
|
||||
.sect .stack
|
||||
;-------------------------------------------------------------------------------
|
||||
; Interrupt Vectors
|
||||
;-------------------------------------------------------------------------------
|
||||
; This stores away the address of where to jump to when the MCU is reset
|
||||
; (Take a look at the linker command file to find the specific address
|
||||
; associated with the section .reset)
|
||||
;-------------------------------------------------------------------------------
|
||||
.sect ".reset" ; MSP430 RESET Vector
|
||||
.short RESET
|
||||
48
content/dxp_Lab4_ArrayFill_c1.c
Normal file
48
content/dxp_Lab4_ArrayFill_c1.c
Normal file
@@ -0,0 +1,48 @@
|
||||
//******************************************************************************
|
||||
// Lab4_ArrayFill.c
|
||||
//
|
||||
// Description; Initialize and fill a 16 element array
|
||||
//
|
||||
// Assembly version by:
|
||||
// D. Phillips, 365_20053; RIT ; 25Mar06 ; Built with CCE for MSP430 V.1.00
|
||||
// Updated for CCS v4 by Dorin Patru 03/20/11
|
||||
//
|
||||
// C version by: Dorin Patru for the EE365 MSP430 Kit - March 2011
|
||||
// C version updated by: Dorin Patru for the LaunchPad Kit - September 2013
|
||||
//******************************************************************************
|
||||
|
||||
#include "msp430g2553.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
|
||||
//------------------------------------------------------------------------------
|
||||
//char type is one byte; int type is two bytes; volatile to prevent optimization
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
volatile unsigned int i=0, j=0, sum=0; // sum is the sum of the indices
|
||||
volatile unsigned int ArrayFill [4][4];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Initialize ArrayFill to 0xff
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
for (i=0; i<=3; i++)
|
||||
for (j=0; j<=3; j++)
|
||||
ArrayFill[i][j] = 0xff;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
// Fill ArrayFill with the indices values and calculate the sum of the indices
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
for (i=0; i<=3; i++)
|
||||
{
|
||||
for (j=0; j<=3; j++)
|
||||
{
|
||||
ArrayFill[i][j] = (4 * i) + j ;
|
||||
sum = sum + ((4 * i) + j) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
sum = sum;
|
||||
}
|
||||
80
content/dxp_Lab5_a1.asm
Normal file
80
content/dxp_Lab5_a1.asm
Normal file
@@ -0,0 +1,80 @@
|
||||
;*******************************************************************************
|
||||
; MSP430 Assembler Code Template for use with TI Code Composer Studio
|
||||
; dxp_Lab5_a1.asm
|
||||
; Displays a clockwise circle
|
||||
; dbp 0301_365_20053
|
||||
; Built with CCE for MSP430 Version: 1.00
|
||||
; Updated for version 4.x.x by Dorin Patru April 2011
|
||||
; Re-coded completely for CCS v5.4, Launch Pad and Capacitive Booster Pack
|
||||
; by Dorin Patru October 2013
|
||||
;*******************************************************************************
|
||||
|
||||
;-------------------------------------------------------------------------------
|
||||
.cdecls C,LIST,"msp430g2553.h" ; Include device header file
|
||||
;-------------------------------------------------------------------------------
|
||||
|
||||
; .data ; presume .data begins at 0x0200
|
||||
SPEED: .word 0x7fff ; display half speed
|
||||
;-------------------------------------------------------------------------------
|
||||
.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
|
||||
;-------------------------------------------------------------------------------
|
||||
clr r10 ; delay counter
|
||||
clr r11 ; LED select
|
||||
bic.b #0xff,&P1DIR ; set up P1 as input
|
||||
bis.b #0xf8,&P1DIR ; set up P1[7:3] as outputs
|
||||
;-------------------------------------------------------------------------------
|
||||
; LEDs 4-1 not elegant display
|
||||
;-------------------------------------------------------------------------------
|
||||
CIRCLE: bic.b #0xf8,&P1OUT ; prepare to display LEDs 1-4
|
||||
bis.b #0x80, &P1OUT ; turn on LED4
|
||||
call #DELAY ; wait around
|
||||
bic.b #0x80, &P1OUT ; turn off LED4
|
||||
bis.b #0x40, &P1OUT ; turn on LED3
|
||||
call #DELAY ; wait around
|
||||
bic.b #0x40, &P1OUT ; turn off LED3
|
||||
bis.b #0x20, &P1OUT ; turn on LED2
|
||||
call #DELAY ; wait around
|
||||
bic.b #0x20, &P1OUT ; turn off LED2
|
||||
bis.b #0x10, &P1OUT ; turn on LED1
|
||||
call #DELAY ; wait around
|
||||
bic.b #0x10, &P1OUT ; turn off LED1
|
||||
;-------------------------------------------------------------------------------
|
||||
; LEDs 5-8 display loop
|
||||
;-------------------------------------------------------------------------------
|
||||
bic.b #0xf8,&P1OUT ; turn out all LEDs
|
||||
bis.b #0xf8,&P1OUT ; prepare to display LEDs 5-8
|
||||
mov.b #0x08, r11 ; prepare r11 for the loop
|
||||
clrc ; clear carry
|
||||
DISP_LOOP rla.b r11 ;
|
||||
jc CIRCLE ; check if you need to display another LED
|
||||
bic.b r11, &P1OUT ; turn on LEDs 5-8
|
||||
call #DELAY ; wait around
|
||||
jmp DISP_LOOP ; jump to display the next LED
|
||||
jmp CIRCLE ; circle again
|
||||
;-------------------------------------------------------------------------------
|
||||
; Delay Subroutine
|
||||
;-------------------------------------------------------------------------------
|
||||
DELAY: mov.w &SPEED,R10
|
||||
MORE_DELAY: dec.w R10 ; Decrement R10
|
||||
jnz MORE_DELAY ; Delay over?
|
||||
ret ; return
|
||||
;-------------------------------------------------------------------------------
|
||||
; Stack Pointer definition
|
||||
;-------------------------------------------------------------------------------
|
||||
.global __STACK_END
|
||||
.sect .stack
|
||||
;-------------------------------------------------------------------------------
|
||||
; Interrupt Vectors
|
||||
;-------------------------------------------------------------------------------
|
||||
.sect ".reset" ; MSP430 RESET Vector
|
||||
.short RESET
|
||||
58
content/dxp_Lab5_c1.c
Normal file
58
content/dxp_Lab5_c1.c
Normal file
@@ -0,0 +1,58 @@
|
||||
//******************************************************************************
|
||||
// Display_Circle.c
|
||||
//
|
||||
// Re-coded completely for CCS v5.4, Launch Pad and Capacitive Booster Pack
|
||||
// by Dorin Patru October 2013
|
||||
//******************************************************************************
|
||||
|
||||
#include <msp430g2553.h>
|
||||
|
||||
unsigned int speed = 0x7FFF; // NOTE: Same delay count as ASM version
|
||||
// Why does it operate slower?
|
||||
|
||||
void delay(void); // Function prototype for delay subroutine
|
||||
|
||||
int main(void){
|
||||
unsigned int i;
|
||||
|
||||
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
|
||||
|
||||
P1DIR &= ~0xFF; // Equivalent to BIC.B #0xFF,&P1DIR
|
||||
P1DIR |= 0xF8; // Equivalent to BIS.B #0xF8,&P1DIR
|
||||
|
||||
while(1){
|
||||
P1OUT &= ~0xF8; // Display LEDs 4-1
|
||||
P1OUT |= 0x80; //
|
||||
delay(); //
|
||||
P1OUT &= ~0x80; //
|
||||
P1OUT |= 0x40; //
|
||||
delay(); //
|
||||
P1OUT &= ~0x40; //
|
||||
P1OUT |= 0x20; //
|
||||
delay(); //
|
||||
P1OUT &= ~0x20; //
|
||||
P1OUT |= 0x10; //
|
||||
delay(); //
|
||||
P1OUT &= ~0x10; //
|
||||
|
||||
P1OUT &= ~0xF8; // Display loop for LEDs 5-8
|
||||
P1OUT |= 0xF8; //
|
||||
for (i=4; i<8; i++)
|
||||
{
|
||||
P1OUT &= ~(1 << i); // () = 2^i
|
||||
delay();
|
||||
P1OUT |= (1 << i);
|
||||
}
|
||||
delay(); // call delay subroutine
|
||||
}
|
||||
}
|
||||
|
||||
void delay(void){
|
||||
unsigned int j;
|
||||
j = speed;
|
||||
j--;
|
||||
while(j > 0){ // software delay
|
||||
j--;
|
||||
j--;
|
||||
}
|
||||
}
|
||||
63
content/dxp_Lab6_a1.asm
Normal file
63
content/dxp_Lab6_a1.asm
Normal file
@@ -0,0 +1,63 @@
|
||||
;*******************************************************************************
|
||||
; MSP-FET430P140 Demo - Generate a PWM signal with TA on TA1
|
||||
; Coded for CCS v5.4 and LaunchPad by Dorin Patru - October 2013
|
||||
;*******************************************************************************
|
||||
;
|
||||
;-------------------------------------------------------------------------------
|
||||
.cdecls C,LIST,"msp430g2553.h" ; Include device header file
|
||||
;-------------------------------------------------------------------------------
|
||||
PWMPeriod .equ 12500 ; ~8x100ms w/ SMCLK / 8
|
||||
PWMDC1 .equ 10000 ; 80% DC
|
||||
PWMDC2 .equ 2500 ; 20% DC
|
||||
SWdelay .equ 0x07ff ; delay value used by the SW timer
|
||||
;-------------------------------------------------------------------------------
|
||||
; Program section
|
||||
;-------------------------------------------------------------------------------
|
||||
.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
|
||||
;-------------------------------------------------------------------------------
|
||||
;;; setup P1.6 as TA OUT1
|
||||
;-------------------------------------------------------------------------------
|
||||
bis.b #BIT6,&P1DIR ; P1.6 output
|
||||
bis.b #BIT6,&P1SEL ; P1.6 peripheral function
|
||||
SetupTA mov #TASSEL1+ID1+ID0+TACLR,&TACTL ; SMCLK, Clear TA
|
||||
; TACTL = uuuu uu11 0000 u100
|
||||
mov #OUTMOD1,&TACCTL1 ;
|
||||
mov #PWMPeriod,&TACCR0 ; ~100ms
|
||||
StartPWM bic #MC1 + MC0,&TACTL ; Stop TA to change the value
|
||||
mov #PWMDC1,&TACCR1 ; Load first PW value in TACCR1
|
||||
bis #MC1 + MC0,&TACTL ; Start TA in up/down mode
|
||||
call #SWtimer ; Call the SW delay routine
|
||||
; to keep this PW for a while
|
||||
bic #MC1 + MC0,&TACTL ; Stop TA to change the value
|
||||
mov #PWMDC2, &TACCR1 ; Now switch the PW
|
||||
bis #MC1 + MC0,&TACTL ; Start TA in up/down mode
|
||||
call #SWtimer ; Call the SW delay routine
|
||||
; to keep this PW for a while
|
||||
jmp StartPWM ;
|
||||
|
||||
;-------------------------------------------------------------------------------
|
||||
SWtimer: mov #SWdelay, r6 ; Load delay value in r5
|
||||
Reloadr5 mov #SWdelay, r5 ; Load delay value in r6
|
||||
ISr50 dec r5 ; Keep this PW for some time
|
||||
jnz ISr50 ; The total SW delay count is
|
||||
dec r6 ; = SWdelay * SWdelay
|
||||
jnz Reloadr5 ;
|
||||
ret ; Return from this subroutine
|
||||
;-------------------------------------------------------------------------------
|
||||
; Stack Pointer definition
|
||||
;-------------------------------------------------------------------------------
|
||||
.global __STACK_END
|
||||
.sect .stack
|
||||
;-------------------------------------------------------------------------------
|
||||
; Interrupt Vectors
|
||||
;-------------------------------------------------------------------------------
|
||||
.sect ".reset" ; MSP430 RESET Vector
|
||||
.short RESET
|
||||
106
content/dxp_Lab7_a1.asm
Normal file
106
content/dxp_Lab7_a1.asm
Normal file
@@ -0,0 +1,106 @@
|
||||
;-------------------------------------------------------------------------------
|
||||
; MSP430 Assembler Code Template for use with TI Code Composer Studio
|
||||
; Toggles the center LED when center "key" on the capacitive touch sensor
|
||||
; is "pressed"
|
||||
;-------------------------------------------------------------------------------
|
||||
.cdecls C,LIST,"msp430.h" ; Include device header file
|
||||
SWdelay .equ 0x0002 ; delay value used by the SW timer
|
||||
;-------------------------------------------------------------------------------
|
||||
; Allocate 2 bytes for the baseline measurement
|
||||
;-------------------------------------------------------------------------------
|
||||
.data
|
||||
.bss meas_base, 2 ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; Allocate another 2 bytes for the current measurement
|
||||
;-------------------------------------------------------------------------------
|
||||
.bss meas_crt, 2 ;
|
||||
;-------------------------------------------------------------------------------
|
||||
.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 from here
|
||||
;-------------------------------------------------------------------------------
|
||||
; Setting up P1.0 to drive center LED
|
||||
;-------------------------------------------------------------------------------
|
||||
bis.b #0xff, &P1DIR ; set up P1 as outputs
|
||||
bic.b #0xff, &P1OUT ; P1 outputs 0
|
||||
;-------------------------------------------------------------------------------
|
||||
; Setting up P2.5 to pin oscillation mode
|
||||
;-------------------------------------------------------------------------------
|
||||
bic.b #BIT5,&P2DIR ; P2.5 input
|
||||
bic.b #BIT5,&P2SEL ;
|
||||
bis.b #BIT5,&P2SEL2 ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; The oscillation from P2.5 is driving INCLK input of TA0
|
||||
; No division of this clock source
|
||||
;-------------------------------------------------------------------------------
|
||||
mov #TASSEL_3, &TA0CTL ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; Setting up to capture the value of TAR on either rising or falling edges
|
||||
; using SW based trigger
|
||||
;-------------------------------------------------------------------------------
|
||||
mov #CM_3 + CCIS_2 + CAP, &TA0CCTL1 ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; Get the baseline reading
|
||||
;-------------------------------------------------------------------------------
|
||||
; Clear TAR and start TA0 in continuous mode; use BIS and not MOV
|
||||
; so that you don't cancel previous settings
|
||||
;-------------------------------------------------------------------------------
|
||||
bis #MC_2 + TACLR, &TA0CTL ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; Call the SW delay routine, which here it is used to provide the accumulation
|
||||
; period; could use instead ACLK fed from VLO
|
||||
;-------------------------------------------------------------------------------
|
||||
call #SWtimer ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; Now, after the accumulation period has passed, generate a SW based
|
||||
; capture trigger by toggeling CCIS0
|
||||
;-------------------------------------------------------------------------------
|
||||
xor #CCIS0, &TA0CCTL1 ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; Save the baseline captured value in meas_base
|
||||
;-------------------------------------------------------------------------------
|
||||
mov TA0CCR1, meas_base ; note the use of the SYMBOLIC AM
|
||||
bic #MC1+MC0, &TA0CTL ; Stop TA
|
||||
sub #2, meas_base ; Adjust the baseline
|
||||
;-------------------------------------------------------------------------------
|
||||
; From here on check again and again the status of the sensor
|
||||
; If it was "pressed", i.e. meas_crt =/= meas_base, toggle the central LED
|
||||
;-------------------------------------------------------------------------------
|
||||
CheckAgain bis #TACLR, &TA0CTL ; Clear TAR
|
||||
bis #MC_2, &TA0CTL ; Continuous Mode
|
||||
call #SWtimer ;
|
||||
xor #CCIS0, &TA0CCTL1 ;
|
||||
mov TA0CCR1, meas_crt ;
|
||||
bic #MC1+MC0, &TA0CTL ;
|
||||
cmp meas_crt, meas_base ;
|
||||
jn NoKey ;
|
||||
xor #1, P1OUT ; Toogle center LED on key "pressed"
|
||||
NoKey nop ; Could do a lot of useful things here
|
||||
jmp CheckAgain ;
|
||||
;-------------------------------------------------------------------------------
|
||||
SWtimer: mov #SWdelay, r6 ; Load delay value in r5
|
||||
Reloadr5 mov #SWdelay, r5 ; Load delay value in r6
|
||||
ISr50 dec r5 ; Keep this PW for some time
|
||||
jnz ISr50 ; The total SW delay count is
|
||||
dec r6 ; = SWdelay * SWdelay
|
||||
jnz Reloadr5 ;
|
||||
ret ; Return from this subroutine
|
||||
;-------------------------------------------------------------------------------
|
||||
; Stack Pointer definition
|
||||
;-------------------------------------------------------------------------------
|
||||
.global __STACK_END
|
||||
.sect .stack
|
||||
|
||||
;-------------------------------------------------------------------------------
|
||||
; Interrupt Vectors
|
||||
;-------------------------------------------------------------------------------
|
||||
.sect ".reset" ; MSP430 RESET Vector
|
||||
.short RESET
|
||||
175
content/dxp_Lab8_a1.asm
Normal file
175
content/dxp_Lab8_a1.asm
Normal file
@@ -0,0 +1,175 @@
|
||||
;-------------------------------------------------------------------------------
|
||||
; MSP430 Assembler Code Template for use with TI Code Composer Studio
|
||||
; Reads sensor status for wheel left, down, right, up, and center button
|
||||
; Saves baseline and crt measurements in two arrays
|
||||
; Updates the status of these sensors in sensor_status
|
||||
; sensor_status can be used to turn on LEDs or trigger other actions
|
||||
; For wheel left turn on LED D1
|
||||
; For wheel down turn on LED D4
|
||||
; For wheel right turn on LED D8
|
||||
; For wheel up turn on LED D5
|
||||
; For turning on each of these LEDs you can define constant values that when
|
||||
; loade in P1OUT will turn on the right LED. Constant array is shown below.
|
||||
; Un-comment to use.
|
||||
;-------------------------------------------------------------------------------
|
||||
.cdecls C,LIST,"msp430.h" ; Include device header file
|
||||
SWdelay .equ 0x0002 ; delay value used by the SW timer
|
||||
;-------------------------------------------------------------------------------
|
||||
; Constant array with the values to turn on LEDs
|
||||
;-------------------------------------------------------------------------------
|
||||
; .sect ".const" ;
|
||||
;LEDdisplay: .byte 0x-- ;
|
||||
; .byte 0x-- ;
|
||||
; .byte 0x-- ;
|
||||
; .byte 0x-- ;
|
||||
; .byte 0x-- ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; Allocate 10 bytes for the baseline values
|
||||
;-------------------------------------------------------------------------------
|
||||
.data
|
||||
.bss meas_base, 10 ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; Allocate another 2 bytes for the current values
|
||||
;-------------------------------------------------------------------------------
|
||||
.bss meas_crt, 10 ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; Allocate one byte for sensor status - to be used by the display routine to
|
||||
; determine which LED to turn on
|
||||
;-------------------------------------------------------------------------------
|
||||
.bss sensor_status, 1 ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; Here begins the code segment
|
||||
;-------------------------------------------------------------------------------
|
||||
.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
|
||||
;-------------------------------------------------------------------------------
|
||||
; Setting up P1 to outputs - will be controlled in the display routine
|
||||
;-------------------------------------------------------------------------------
|
||||
bis.b #0xff, &P1DIR ; set up P1 as outputs
|
||||
bic.b #0xff, &P1OUT ; P1 outputs 0
|
||||
;-------------------------------------------------------------------------------
|
||||
; The real mainloop starts here
|
||||
;-------------------------------------------------------------------------------
|
||||
call #meas_base_val ; do this once
|
||||
Mainloop call #meas_crt_val ;
|
||||
call #det_sensor ;
|
||||
call #display ;
|
||||
jmp Mainloop ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; End mainloop ==> all subroutines from here on
|
||||
;-------------------------------------------------------------------------------
|
||||
; Measure base line values routine
|
||||
;-------------------------------------------------------------------------------
|
||||
meas_base_val: mov.b #0x02, R5 ; initialize R5 to point to P2.x
|
||||
mov.b #0x00, R6 ; initialize R6 to the base of meas_base
|
||||
meas_base_again call #meas_setup ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; Clear TAR and start TA0 in continuous mode; use BIS and not MOV
|
||||
; so that you don't cancel previous settings
|
||||
;-------------------------------------------------------------------------------
|
||||
bis #MC_2 + TACLR, &TA0CTL ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; Call the SW delay routine, which here it is used to provide the accumulation
|
||||
; period; could use instead ACLK fed from VLO
|
||||
;-------------------------------------------------------------------------------
|
||||
call #SWtimer ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; Now, after the accumulation period has passed, generate a SW based
|
||||
; capture trigger by toggeling CCIS0
|
||||
;-------------------------------------------------------------------------------
|
||||
xor #CCIS0, &TA0CCTL1 ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; Save the baseline captured value in meas_base array
|
||||
;-------------------------------------------------------------------------------
|
||||
mov TA0CCR1, meas_base(R6) ; note the use of the SYMBOLIC AM
|
||||
bic #MC1+MC0, &TA0CTL ; Stop TA
|
||||
sub #2, meas_base(R6) ; Adjust this baseline
|
||||
bic.b R5,&P2SEL2 ; Stop the oscillation on the crt. pin
|
||||
rla.b R5 ; Prepare next x
|
||||
add.b #0x02, R6 ; Prepare the next index into the array
|
||||
cmp.b #0x40, R5 ; Check if done with all five sensors
|
||||
jnz meas_base_again ;
|
||||
ret ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; Measure current values routine
|
||||
;-------------------------------------------------------------------------------
|
||||
meas_crt_val: mov.b #0x02, R5 ; initialize R5 to point to P2.1
|
||||
mov.b #0x00, R6 ; initialize R6 to the base of meas_base
|
||||
meas_crt_again call #meas_setup ;
|
||||
bis #MC_2 + TACLR, &TA0CTL ; Continuous, Clear TAR
|
||||
call #SWtimer ;
|
||||
xor #CCIS0, &TA0CCTL1 ; Trigger SW capture
|
||||
mov TA0CCR1, meas_crt(R6) ; Save captured value in array
|
||||
bic #MC1+MC0, &TA0CTL ; Stop timer
|
||||
bic.b R5,&P2SEL2 ; Stop the oscillation on the crt. pin
|
||||
rla.b R5 ; Prepare next x
|
||||
add.b #0x02, R6 ; Prepare the next index into the array
|
||||
cmp.b #0x40, R5 ; Check if done with all five sensors
|
||||
jnz meas_crt_again ;
|
||||
ret ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; Determine which sensor was pressed routine
|
||||
;-------------------------------------------------------------------------------
|
||||
det_sensor: clr.b sensor_status ;
|
||||
mov.b #0x02, R5 ; initialize R5 to point to P2.1
|
||||
mov.b #0x00, R6 ; initialize R6 to the base of meas_base
|
||||
CheckNextSensor cmp meas_crt(R6), meas_base(R6) ;
|
||||
jn NotThisSensor ;
|
||||
bis.b R5, sensor_status ; Update sensor_status
|
||||
NotThisSensor rla.b R5 ; Prepare next x
|
||||
add.b #0x02, R6 ; Prepare the next index into the array
|
||||
cmp.b #0x40, R5 ; Check if done with all five sensors
|
||||
jnz CheckNextSensor ;
|
||||
ret ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; Display routine. To be filled in by you. Turn on the LED that corresponds
|
||||
; to the 1 position in sensor_status.
|
||||
;-------------------------------------------------------------------------------
|
||||
display: nop ;
|
||||
ret ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; Setting up P2.x and TA for the next measurement routine
|
||||
;-------------------------------------------------------------------------------
|
||||
; Setting up P2.x to pin oscillation mode
|
||||
;-------------------------------------------------------------------------------
|
||||
meas_setup: bic.b R5,&P2DIR ; P2.x input
|
||||
bic.b R5,&P2SEL ;
|
||||
bis.b R5,&P2SEL2 ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; The oscillation from P2.x is driving INCLK input of TA0
|
||||
; No division of this clock source
|
||||
;-------------------------------------------------------------------------------
|
||||
mov #TASSEL_3, &TA0CTL ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; Setting up to capture the value of TAR on either rising or falling edges
|
||||
; using SW based trigger
|
||||
;-------------------------------------------------------------------------------
|
||||
mov #CM_3 + CCIS_2 + CAP, &TA0CCTL1 ;
|
||||
ret ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; SW delay routine
|
||||
;-------------------------------------------------------------------------------
|
||||
SWtimer: mov #SWdelay, r8 ; Load delay value in r5
|
||||
Reloadr7 mov #SWdelay, r7 ; Load delay value in r6
|
||||
ISr70 dec r7 ; Keep this PW for some time
|
||||
jnz ISr70 ; The total SW delay count is
|
||||
dec r8 ; = SWdelay * SWdelay
|
||||
jnz Reloadr7 ;
|
||||
ret ; Return from this subroutine
|
||||
;-------------------------------------------------------------------------------
|
||||
; Stack Pointer definition
|
||||
;-------------------------------------------------------------------------------
|
||||
.global __STACK_END
|
||||
.sect .stack
|
||||
;-------------------------------------------------------------------------------
|
||||
; Interrupt Vectors
|
||||
;-------------------------------------------------------------------------------
|
||||
.sect ".reset" ; MSP430 RESET Vector
|
||||
.short RESET
|
||||
87
content/dxp_Lab9_a1.asm
Normal file
87
content/dxp_Lab9_a1.asm
Normal file
@@ -0,0 +1,87 @@
|
||||
;-------------------------------------------------------------------------------
|
||||
; MSP430 Assembler Code Template for use with TI Code Composer Studio
|
||||
;
|
||||
;
|
||||
;-------------------------------------------------------------------------------
|
||||
.cdecls C,LIST,"msp430g2553.h" ; Include device header file
|
||||
;-------------------------------------------------------------------------------
|
||||
; R/W Data
|
||||
;-------------------------------------------------------------------------------
|
||||
.bss ADC_SW_FLAG,1 ;
|
||||
;-------------------------------------------------------------------------------
|
||||
.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
|
||||
;-------------------------------------------------------------------------------
|
||||
;
|
||||
;-------------------------------------------------------------------------------
|
||||
clr.b &ADC_SW_FLAG ; Clear ADC SW flag
|
||||
clr.w r5 ; Register used to store and process the sample value
|
||||
; after its acquisition
|
||||
;-------------------------------------------------------------------------------
|
||||
; Select analog function on P1.0, i.e. pin2 of the 20PDIP package
|
||||
;-------------------------------------------------------------------------------
|
||||
; bis.b #0x01, &ADC10AE0 ; P1.0 on pin 2 analog function enabled
|
||||
;-------------------------------------------------------------------------------
|
||||
; Main loop from here
|
||||
;-------------------------------------------------------------------------------
|
||||
Mainloop call #ACQUIRE ;
|
||||
jmp Mainloop ;
|
||||
;-------------------------------------------------------------------------------
|
||||
ACQUIRE:
|
||||
clr.w &ADC10CTL0 ; Clear configuration registers just in case
|
||||
clr.w &ADC10CTL1 ; some values were left on by a prior routine
|
||||
;-------------------------------------------------------------------------------
|
||||
; ADC10CTL0 configuration based on the CLR instruction above and the one below:
|
||||
; SREF=001, ADC10SHT=64*ADC10CLKs, ADC10SR=0, REFOUT=0, REFBURST=0, MSC=0,
|
||||
; REF2_5=0, REFON=1, ADC10ON=1, ADC10IE=1, ADC10IFG=0, ENC=0, ADC10SC=0
|
||||
;-------------------------------------------------------------------------------
|
||||
bis.w #(SREF_1 + ADC10SHT_3 + REFON + ADC10ON + ADC10IE), &ADC10CTL0 ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; ADC10CTL1 configuration based on the CLR instruction above and the ones below:
|
||||
; INCH=1010, SHS=00, ADC10DF=0, ISSH=0, ADC10DIV=/8, ADC10SSEL=00,
|
||||
; CONSEQ=00, ADC10BUSY=0
|
||||
;-------------------------------------------------------------------------------
|
||||
bis.w #(INCH_10 + ADC10DIV_7), &ADC10CTL1 ; Input channel = int. temp. diode
|
||||
eint ; Enable general interrupts
|
||||
clrz ; Clear Z
|
||||
clr.b &ADC_SW_FLAG ; Clear ADC SW FLAG
|
||||
bis.w #(ENC + ADC10SC), &ADC10CTL0 ; Start a conversion
|
||||
CheckFlag tst.b &ADC_SW_FLAG ; Check to see if ADC10_ISR was
|
||||
jz CheckFlag ; executed
|
||||
dint ; Disable general interrupts
|
||||
clr.w &ADC10CTL0 ; Clear configuration registers
|
||||
clr.w &ADC10CTL1 ; Safe practice
|
||||
ret ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; Interrupt Service Routines
|
||||
;-------------------------------------------------------------------------------
|
||||
ADC10_ISR:
|
||||
nop ;
|
||||
bic.w #ADC10IFG, &ADC10CTL0 ;
|
||||
mov.w &ADC10MEM, r5 ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; Set the ADC SW flag, which is continuously checked by the ACQUIRE routine
|
||||
;-------------------------------------------------------------------------------
|
||||
mov.b #0x01, &ADC_SW_FLAG ;
|
||||
reti ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; Stack Pointer definition
|
||||
;-------------------------------------------------------------------------------
|
||||
.global __STACK_END
|
||||
.sect .stack
|
||||
;-------------------------------------------------------------------------------
|
||||
; Interrupt Vectors
|
||||
;-------------------------------------------------------------------------------
|
||||
.sect ".reset" ; MSP430 RESET Vector
|
||||
.short RESET
|
||||
;-------------------------------------------------------------------------------
|
||||
.sect ".int05" ; ADC10 Vector
|
||||
isr_adc10: .short ADC10_ISR ;
|
||||
.end
|
||||
Reference in New Issue
Block a user