Cov txheej txheem:
- Kauj Ruam 1: Kev nkag siab
- Kauj Ruam 2: Qhov Chaw Pib Pib
- Kauj Ruam 3: Ultra Low Power
- Kauj ruam 4: TIMER
- Kauj Ruam 5: Hom Tsawg Zog
- Kauj Ruam 6: ISR-Timer
- Kauj Ruam 7: Kho vajtse cuam tshuam
- Kauj Ruam 8: ISR- Pib dua/ Laub Khawm
- Kauj ruam 9: CODE
- Kauj Ruam 10: Cov Cai Siv
Video: MSP430 Seconds Counter: 10 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:27
Txais tos! Ua Tus Thib Ob Lub Sijhawm: Siv CCStudio 8 thiab MSP430F5529 rau txoj haujlwm.
C hom lus rau tus lej tswj hwm micro. Ua Ntawv Thov Lub Hwj Huam Tsawg, Timers thiab cuam tshuam. Qhov tso tawm tau tshwm ntawm 7 Segment.
Kauj Ruam 1: Kev nkag siab
Cia Peb Pib!
Pib lub sijhawm saib xyuas lub sijhawm rau OFF lub xeev siv tus lej xav tau rau lub sijhawm saib xyuas (Nws pab txhawm rau txheeb xyuas qhov tsis muaj qhov kawg, ua kom lub tshuab ua haujlwm nyab xeeb).
#suav nrog
/** * main.c */
int main (tsis muaj dab tsi)
{
WDTCTL = WDTPW | WDTHOLD; // nres lub moos timer
rov 0;
}
Kauj Ruam 2: Qhov Chaw Pib Pib
{
P3DIR = 0xFF; // P3DIR = 0x00;
P6DIR = 0xFF;
P4DIR | = 0x00;
P4REN | = 0xFF;
P4OUT | = 0xFF;
}
P3DIR | = 0x00 qhia peb tias tag nrho ntawm PORT-3 tau pib ua kom tau txais cov tswv yim.
P3DIR | = 0xFF qhia peb tias tag nrho ntawm PORT-3 tau pib ua ntej los muab cov txiaj ntsig.
P3DIR | = 0x01 tsuas yog tus pin P3.0 tau pib ua ntej rau hauv PORT-3. Qhov no ua raws Hexadecimal Port koog.
P4REN | = 0xFF, qhov no qhia tau hais tias cov pins ntawm PORT-4 muaj lawv rub tawm/nqis resistors qhib.
Txhawm rau xaiv lawv ntawm Rub UP lossis Rub DOWN, kev qhia P $ OUT | = 0xFF tau siv.
Yog tias 0xFF raug siv lawv teeb tsa raws li Rub UP resistors thiab yog 0x00 lawv teeb tsa raws li Rub DOWN.
Kauj Ruam 3: Ultra Low Power
MSP430F5529 tso cai rau peb kom txo hwj chim poob los ntawm tus txheej txheem. Qhov no muaj txiaj ntsig hauv daim ntawv thov ib leeg.
Qhov no hu rau tshaj tawm ntawm txhua tus pin lossis Ports rau cov zis.
{
P7DIR | = 0xFF;
P6DIR | = 0xFF;
P5DIR | = 0xFF;
P4DIR | = 0xFF;
P3DIR | = 0xFF;
P2DIR | = 0xFF;
P1DIR | = 0xFF;
}
Kauj ruam 4: TIMER
Kev siv timer rau ncua sijhawm ntawm ib thib ob. Qhov no siv SMCLK ntawm 1MHz, tseem siv sijhawm ua haujlwm nyob rau hauv Lub zog qis (nyob rau theem tom ntej, tom qab suav nws cuam tshuam los ntawm LPM). Cov txheej txheem no txuag lub zog thiab lub nra ntawm tus neeg ua haujlwm
TA0CCTL0 = CCIE;
TA0CCR0 = 999;
TA0CTL = TASSEL_2 + MC_1;
Qhov muaj txiaj ntsig yog 999, raws li siv ib qho ntxiv suav rov qab rau xoom hauv lub sijhawm teev npe.
Kauj Ruam 5: Hom Tsawg Zog
_BIS_SR (LPM0_bits+GIE);
Qhov no ua rau General cuam tshuam Enable (GIE), thiab tso CPU rau LPM0, qhov twg MCLK uas txhawb nqa cpu tawm, thiab SMCLK thiab ACLK khiav uas ua kom lub sijhawm ua haujlwm. yog li peb tuaj yeem pom CPU raug kaw, nyob ntawd los ntawm kev txuag lub zog.
Kauj Ruam 6: ISR-Timer
#pragma vector = TIMER0_A0_VECTOR
_ cuam tshuam void Timer_A (tsis muaj dab tsi)
{
z ++;
yog (z> ncua)
{
P3OUT = code [x];
P6OUT = code1 [y];
x ++;
yog tias (x == 10)
{
x = 0;
y ++;
}
yog tias (y == 6)
y = 0;
z = 0;
}
}
pragma vector yog rau ISR sawv cev hauv C embd.
code [x] thiab code1 [y] yog cov arrays uas muaj cov txiaj ntsig tso tawm rau ob xya ntu, rau kev tso saib 60 vib nas this.
Kauj Ruam 7: Kho vajtse cuam tshuam
P2DIR = 0x00;
P2REN = 0x02;
P2OUT = 0x02;
P2IE | = BIT1;
P2IES | = BIT1;
P2IFG & = ~ BIT1;
Ntawm no P2.1 tau tshaj tawm tias yog kho vajtse cuam tshuam, yog tias khawm raug nias, lub txee rov ua dua tus nqi.
qhov kev zov me nyuam tau sau hauv ISR ntawm qhov cuam tshuam no.
Kauj Ruam 8: ISR- Pib dua/ Laub Khawm
#pragma vector = PORT2_VECTOR
_ cuam tshuam qhov tsis muaj chaw nres nkoj_2 (tsis muaj dab tsi)
{
P2IFG & = ~ BIT1;
x = 0; y = 0;
P3OUT = code [x];
P6OUT = code1 [y];
v ++;
rau (i = 0; i
{
P1OUT | = BIT0; //P1.0 = toggle
_delay_cycles (1048576);
P1OUT & = ~ BIT0; // P1.0 = toggle
_delay_cycles (1048576);
}
Qhov ISR no rov ua dua lub txee, thiab khaws qhov suav pes tsawg zaus qhov seem raug nias.
(Nov yog cov zaub tau ua los ntawm kev hloov pauv, tseem tuaj yeem siv lwm qhov array thiab lub sijhawm, los qhia cov txiaj ntsig raws li tso tawm hauv 7 ntu).
Kauj ruam 9: CODE
#suav nrog
#define ncua 1000
char code = {0xFC, 0x60, 0xDA, 0xF2, 0x66, 0xB6, 0xBE, 0xE0, 0xFE, 0xE6};
char code1 = {0x7E, 0x30, 0x6D, 0x79, 0x33, 0x5B};
volatile unsigned int x = 0, y = 0, z = 0;
volatile unsigned int v = 0, kuv = 0;
void lub ntsiab ()
{
WDTCTL = WDTPW | WDTHOLD; // nres lub moos timer
P7DIR | = 0xFF;
P7OUT | = 0x00;
P8DIR | = 0xFF;
P8OUT | = 0x00;
P4DIR | = 0xFF;
P4OUT | = 0x00;
P5DIR | = 0xFF;
P5OUT | = 0x00;
P1DIR = 0xFF;
P3DIR = 0xFF;
P6DIR = 0xFF;
P2DIR = 0x00;
P2REN = 0x02;
P2OUT = 0x02;
P2IE | = BIT1;
P2IES | = BIT1;
P2IFG & = ~ BIT1;
TA0CCTL0 = CCIE;
TA0CCR0 = 999;
TA0CTL = TASSEL_2 + MC_1;
_BIS_SR (LPM0_bits+GIE);
}
// Timer A0 cuam tshuam kev pabcuam niaj hnub
#pragma vector = TIMER0_A0_VECTOR
_ cuam tshuam void Timer_A (tsis muaj dab tsi)
{
z ++;
yog (z> ncua)
{
P3OUT = code [x];
P6OUT = code1 [y];
x ++;
yog tias (x == 10)
{
x = 0;
y ++;
}
yog tias (y == 6)
y = 0;
z = 0;
}
}
// Kho vajtse cuam tshuam kev pabcuam niaj hnub
#pragma vector = PORT2_VECTOR
_ cuam tshuam void chaw nres nkoj_2 (tsis muaj dab tsi)
{
P2IFG & = ~ BIT1;
x = 0;
y = 0;
P3OUT = code [x];
P6OUT = code1 [y];
v ++;
rau (i = 0; i
{P1OUT | = BIT0; // P1.0 = toggle
_day_cycles (1048576);
P1OUT & = ~ BIT0; // P1.0 = toggle
_day_cycles (1048576);
}
}
Kauj Ruam 10: Cov Cai Siv
GitHub Repository
Pom zoo:
Arduino Tsheb Rov Qab Chaw Nres Tsheb Ceeb Toom - Cov Kauj Ruam ntawm Kauj Ruam: 4 Kauj Ruam
Arduino Tsheb Rov Qab Chaw Nres Tsheb Ceeb Toom | Cov kauj ruam ib kauj ruam: Hauv txoj haujlwm no, kuv yuav tsim qhov yooj yim Arduino Tsheb Rov Qab Tsheb Nres Tsheb Nres Sensor Siv Arduino UNO thiab HC-SR04 Ultrasonic Sensor. Qhov no Arduino raws Lub Tsheb Rov Qab ceeb toom tuaj yeem siv rau Kev Tshawb Fawb Txog Tus Kheej, Robot Ranging thiab lwm yam
Finite State Machine ntawm MSP430: 6 Cov Kauj Ruam
Finite State Machine ntawm MSP430: Kuv yuav qhia koj yuav ua li cas rau nruab MSP430G2 Launchpad nrog Finite State Machine (FSM) siv YAKINDU Statechart Tools ncaj qha hauv Texas Instruments Code Composer Studio. Cov ntawv qhia no muaj rau qib rau qib: Txhim kho YAKINDU Statechart Cov Cuab Yeej li
MSP430 Breadboard Audio Spectrum Analyzer: 6 Kauj Ruam
MSP430 Breadboard Audio Spectrum Analyzer: Txoj haujlwm no yog microphone raws thiab xav tau yam khoom me me sab nraud. 2 x LR44 npib hlwb tau siv yog li kuv tuaj yeem muaj tag nrho cov qauv ua haujlwm hauv qhov txwv ntawm 170 khi-point mini breadboard. ADC10, TimerA cuam tshuam LPM sawv, TimerA PWM
Programming MSP430 DIP Siv Ez430: 4 Cov Kauj Ruam
Programming MSP430 DIP Siv Ez430: Thaum Kuv pom TI's ez430 USB programmer, nws zoo li yog ib txoj hauv kev yooj yim rau sawv thiab khiav nrog MCU. Kuv yuav yuam kev li cas, nws muaj ez hauv lub npe! Nws hloov tawm tias nws yog qhov yooj yim … feem ntau.Ez430 zoo heev yog tias koj xav tau
Till All Data on a CD/DVD in 5 Seconds or Less.: 3 Kauj Ruam
Till All Data on a CD/DVD in 5 Seconds or Less.: Till All Data on a CD/DVD in 5 seconds or less.Why would you want to do this: ++ Destroy old backups of a few years ++ Nco koj hlawv lub sijhawm tshwj xeeb hauv chav pw rau DVD ++ Koj Ex xav tau CD/DVD rov qab. ++ lom zem nrog AOL DISK !!!! LOL