1357 views|0 replies

1668

Posts

0

Resources
The OP
 

MSP430 MCU comprehensive example (proteus) [Copy link]

I have been learning about the msp430 microcontroller for a while recently. I feel that this low-power microcontroller is very interesting. Although I have not yet fully understood its specific operation, some simple programs have been implemented. The following is a more comprehensive program I wrote for MSP430, and I would like to share it with you:
Main program:

#include<msp430x24x.h>
#include"liushui.h"
#include"juzhen.h"
#define uchar unsigned char
#define uint unsigned int
#define rs_0 P6OUT&=~BIT4;
#define rs_1 P6OUT|=BIT4;
#define rw_0 P6OUT&=~BIT5;
#define rw_1 P6OUT|=BIT5;
#define e_0 P6OUT&=~BIT6
#define e_1 P6OUT|=BIT6;
#define wei1_0 P6OUT&=~BIT0;
#define wei1_1 P6OUT|=BIT0;
#define wei2_1 P6OUT|= BIT1;
#define wei3_0 P6OUT&=~BIT2;
#define wei3_1 P6OUT|=BIT2;
#define wei4_0 P6OUT&=~BIT3;
#define wei4_1 P6OUT|=BIT3;
uint j,t,count1,count2,count3,count4=99;
uchar temp1,temp2;
const uchar table1[]={" shizhong dabao "};
const uchar table2[ ]="0123456789";
const uchar table3[]=" 15:45:00 ";
void delay2(uint x)
{
uint y;
while(x--)
for(y=120;y>0;y--) ;
}
void w_com(uchar com)
{
rs_0; P2OUT
=com; delay2 (
1);
e_1 ;
e_0 ;
} void
w_dat(uchar dat)
{ rs_1 ; () { w_com(0x38); w_com(0x0c); w_com(0x06); w_com(0x01); w_com(0x80); } void keyscan2() { if(P1IN==0xfe) { delay2(1); while(P1IN==0xfe ); count2++; if(count2==60) count2=0; temp1=count2/10; temp2=count2; w_com(0x86+0x40); w_dat(table2[temp1]); delay2(5); w_com(0x87+0x40 ); w_dat(table2[temp2]); } if(P1IN==0xfd) { delay2(1); while(P1IN==0xfd); count3++; if(count3==24) count3=0; temp1=count3/10 ; temp2=count3; w_com(0x83+0x40); w_dat(table2[temp1]); delay2(5); w_com(0x84+0x40); w_dat(table2[temp2]); } } void shuma() { temp1=count4/10; temp2= count4; wei1_0; P5OUT=count5; delay2(1); wei1_1;






















































This post is from Microcontroller MCU
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list