SlideShare a Scribd company logo
1 of 2
#include "io430.h"
#include "intrinsics.h"
#define TEMP 1000
unsigned int digitos[10] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
unsigned int mudar[10] = {0X04,0X08,0X10,0x20};
//unsigned int mudar[10] = {0B000001,0B000010,0B000100,0B001000};
// 0B0000 0100 0B0000 1000 0B0001 0000 0B0010 0000
// 0000-0001 , 0000-0010, 0000-0100, 0000-1000,
// 0X01, 0X02, 0X04, 0x08
int main(void)
{
// Stop watchdog timer to prevent time out reset
int aguarde(long);
int ler_bit(char a, int b);
WDTCTL = WDTPW + WDTHOLD;
//Configura digitos 1 al 4
P1DIR = 0x7F; // 0111-1111 <- coloca 1 de 0 a 6 e 0 no porta 7
P2DIR = 0xFC; // 1111 - 1100 <-1000
int disp_1 = 0, disp_2 = 0, disp_3 = 0, disp_4 = 0;
while(1){
if((ler_bit(P1IN,7) == 1)){
// while(1)
do{
P2OUT = mudar[0];
P1OUT = digitos[disp_1];
aguarde(TEMP);
P2OUT = mudar[1];
P1OUT = digitos[disp_2];
aguarde(TEMP);
P2OUT = mudar[2];
P1OUT = digitos[disp_3];
aguarde(TEMP);
P2OUT = mudar[3];
P1OUT = digitos[disp_4];
aguarde(TEMP);
disp_1++;
if(disp_1 == 10){
disp_1 = 0;
disp_2++;
} if(disp_2 == 10){
disp_2 = 0;
disp_3++;
}if(disp_3 == 10){
disp_3 = 0;
disp_4++;
}if(disp_4 == 10)
disp_4 = 0;
//}while((ler_bit(P1IN,7))||(ler_bit(P2IN,0))||(ler_bit(P2IN,1)));
}while((ler_bit(P2IN,0))||(ler_bit(P2IN,1)));
//break;
}
if(~((ler_bit(P1IN,7))||(ler_bit(P2IN,0))||(ler_bit(P2IN,1)))){
P2OUT = mudar[0];
P1OUT = digitos[disp_1];
aguarde(TEMP);
P2OUT = mudar[1];
P1OUT = digitos[disp_2];
aguarde(TEMP);
P2OUT = mudar[2];
P1OUT = digitos[disp_3];
aguarde(TEMP);
P2OUT = mudar[3];
P1OUT = digitos[disp_4];
aguarde(TEMP);
}
//Mostrar en cada digito un valor
if(ler_bit(P2IN,1)){
// while(1)
do{
P2OUT = mudar[0];
P1OUT = digitos[7];
aguarde(TEMP);
P2OUT = mudar[1];
P1OUT = digitos[6];
aguarde(TEMP);
P2OUT = mudar[2];
P1OUT = digitos[1];
aguarde(TEMP);
P2OUT = mudar[3];
P1OUT = digitos[5];
aguarde(TEMP);
}while((ler_bit(P1IN,7))||(ler_bit(P2IN,0))||(ler_bit(P2IN,1)));
//break;
}
}}
int ler_bit(char a, int b)
{
char var = (1 << b);
if(var == (a & var))
return 1;
else
return 0;
}
int aguarde(long t0)
{
long y=0;
while(y++ < t0);
return 1;
}

More Related Content

What's hot (13)

04 2 오버플로 상수 매크로
04 2 오버플로 상수 매크로04 2 오버플로 상수 매크로
04 2 오버플로 상수 매크로
 
Michael kontopoulo1s
Michael kontopoulo1sMichael kontopoulo1s
Michael kontopoulo1s
 
Ssaw08 0624
Ssaw08 0624Ssaw08 0624
Ssaw08 0624
 
verilog coding of butterfly diagram
verilog coding of butterfly diagram verilog coding of butterfly diagram
verilog coding of butterfly diagram
 
8 point DFT
8 point DFT8 point DFT
8 point DFT
 
Javascript: The Important Bits
Javascript: The Important BitsJavascript: The Important Bits
Javascript: The Important Bits
 
oop Lecture 4
oop Lecture 4oop Lecture 4
oop Lecture 4
 
Tai lieu ky thuat lap trinh
Tai lieu ky thuat lap trinhTai lieu ky thuat lap trinh
Tai lieu ky thuat lap trinh
 
Chat code
Chat codeChat code
Chat code
 
2² C# 4.0 and .NET 4 Selected Features
2² C# 4.0 and .NET 4 Selected Features2² C# 4.0 and .NET 4 Selected Features
2² C# 4.0 and .NET 4 Selected Features
 
Funcion matematica
Funcion matematicaFuncion matematica
Funcion matematica
 
Real Life Uses of a Program (Tik Tok Toy Game) useing by C Programming
Real Life Uses of a Program (Tik Tok Toy Game) useing by C Programming Real Life Uses of a Program (Tik Tok Toy Game) useing by C Programming
Real Life Uses of a Program (Tik Tok Toy Game) useing by C Programming
 
Robot Motion Source code
Robot Motion Source codeRobot Motion Source code
Robot Motion Source code
 

Viewers also liked

Portifolio SuperBaja UERJ
Portifolio SuperBaja UERJPortifolio SuperBaja UERJ
Portifolio SuperBaja UERJBruno de Brito
 
Acceleration Modelling of EV1_FR8695
Acceleration Modelling of EV1_FR8695Acceleration Modelling of EV1_FR8695
Acceleration Modelling of EV1_FR8695Siddhesh Ozarkar
 
Trabalho mini baja processos de fabric ii
Trabalho mini baja   processos de fabric iiTrabalho mini baja   processos de fabric ii
Trabalho mini baja processos de fabric iiJorge Luiz Binotto
 
Baja 2013 rbsb_3_-_competicao_baja_sae_brasil_-_emenda_0
Baja 2013 rbsb_3_-_competicao_baja_sae_brasil_-_emenda_0Baja 2013 rbsb_3_-_competicao_baja_sae_brasil_-_emenda_0
Baja 2013 rbsb_3_-_competicao_baja_sae_brasil_-_emenda_0Jonatas Ferreira
 
Projeto baja ifpb (1) pronto
Projeto baja ifpb (1) prontoProjeto baja ifpb (1) pronto
Projeto baja ifpb (1) prontoNando Mathias
 
Apresentação tfg mini baja sae brasil rev s
Apresentação tfg mini baja sae brasil rev sApresentação tfg mini baja sae brasil rev s
Apresentação tfg mini baja sae brasil rev sGuilherme Pereira
 
DETERMINAÇÃO DO COEFICIENTE DE ARRASTO AERODINÂMICO PARA UM VEÍCULO DO TIPO B...
DETERMINAÇÃO DO COEFICIENTE DE ARRASTO AERODINÂMICO PARA UM VEÍCULO DO TIPO B...DETERMINAÇÃO DO COEFICIENTE DE ARRASTO AERODINÂMICO PARA UM VEÍCULO DO TIPO B...
DETERMINAÇÃO DO COEFICIENTE DE ARRASTO AERODINÂMICO PARA UM VEÍCULO DO TIPO B...Rafael Delmunde
 
Circuito com arduino e optoacopladores
Circuito com arduino e optoacopladoresCircuito com arduino e optoacopladores
Circuito com arduino e optoacopladoresNando Mathias
 
Casestudy3_TeamPulverisers5_MITPune - report
Casestudy3_TeamPulverisers5_MITPune - reportCasestudy3_TeamPulverisers5_MITPune - report
Casestudy3_TeamPulverisers5_MITPune - reportSiddhesh Ozarkar
 
Zero Turn Radius Report - Team Panache (1)
Zero Turn Radius Report - Team Panache (1)Zero Turn Radius Report - Team Panache (1)
Zero Turn Radius Report - Team Panache (1)Siddhesh Ozarkar
 

Viewers also liked (12)

Portifolio SuperBaja UERJ
Portifolio SuperBaja UERJPortifolio SuperBaja UERJ
Portifolio SuperBaja UERJ
 
Acceleration Modelling of EV1_FR8695
Acceleration Modelling of EV1_FR8695Acceleration Modelling of EV1_FR8695
Acceleration Modelling of EV1_FR8695
 
Trabalho mini baja processos de fabric ii
Trabalho mini baja   processos de fabric iiTrabalho mini baja   processos de fabric ii
Trabalho mini baja processos de fabric ii
 
Baja 2013 rbsb_3_-_competicao_baja_sae_brasil_-_emenda_0
Baja 2013 rbsb_3_-_competicao_baja_sae_brasil_-_emenda_0Baja 2013 rbsb_3_-_competicao_baja_sae_brasil_-_emenda_0
Baja 2013 rbsb_3_-_competicao_baja_sae_brasil_-_emenda_0
 
Projeto baja ifpb (1) pronto
Projeto baja ifpb (1) prontoProjeto baja ifpb (1) pronto
Projeto baja ifpb (1) pronto
 
Apresentação tfg mini baja sae brasil rev s
Apresentação tfg mini baja sae brasil rev sApresentação tfg mini baja sae brasil rev s
Apresentação tfg mini baja sae brasil rev s
 
DETERMINAÇÃO DO COEFICIENTE DE ARRASTO AERODINÂMICO PARA UM VEÍCULO DO TIPO B...
DETERMINAÇÃO DO COEFICIENTE DE ARRASTO AERODINÂMICO PARA UM VEÍCULO DO TIPO B...DETERMINAÇÃO DO COEFICIENTE DE ARRASTO AERODINÂMICO PARA UM VEÍCULO DO TIPO B...
DETERMINAÇÃO DO COEFICIENTE DE ARRASTO AERODINÂMICO PARA UM VEÍCULO DO TIPO B...
 
Circuito com arduino e optoacopladores
Circuito com arduino e optoacopladoresCircuito com arduino e optoacopladores
Circuito com arduino e optoacopladores
 
Casestudy3_TeamPulverisers5_MITPune - report
Casestudy3_TeamPulverisers5_MITPune - reportCasestudy3_TeamPulverisers5_MITPune - report
Casestudy3_TeamPulverisers5_MITPune - report
 
Zero Turn Radius Report - Team Panache (1)
Zero Turn Radius Report - Team Panache (1)Zero Turn Radius Report - Team Panache (1)
Zero Turn Radius Report - Team Panache (1)
 
BAJA 2014 presentation
BAJA 2014 presentationBAJA 2014 presentation
BAJA 2014 presentation
 
FR8695_IndProj
FR8695_IndProjFR8695_IndProj
FR8695_IndProj
 

MSP430_4-digit_display

  • 1. #include "io430.h" #include "intrinsics.h" #define TEMP 1000 unsigned int digitos[10] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; unsigned int mudar[10] = {0X04,0X08,0X10,0x20}; //unsigned int mudar[10] = {0B000001,0B000010,0B000100,0B001000}; // 0B0000 0100 0B0000 1000 0B0001 0000 0B0010 0000 // 0000-0001 , 0000-0010, 0000-0100, 0000-1000, // 0X01, 0X02, 0X04, 0x08 int main(void) { // Stop watchdog timer to prevent time out reset int aguarde(long); int ler_bit(char a, int b); WDTCTL = WDTPW + WDTHOLD; //Configura digitos 1 al 4 P1DIR = 0x7F; // 0111-1111 <- coloca 1 de 0 a 6 e 0 no porta 7 P2DIR = 0xFC; // 1111 - 1100 <-1000 int disp_1 = 0, disp_2 = 0, disp_3 = 0, disp_4 = 0; while(1){ if((ler_bit(P1IN,7) == 1)){ // while(1) do{ P2OUT = mudar[0]; P1OUT = digitos[disp_1]; aguarde(TEMP); P2OUT = mudar[1]; P1OUT = digitos[disp_2]; aguarde(TEMP); P2OUT = mudar[2]; P1OUT = digitos[disp_3]; aguarde(TEMP); P2OUT = mudar[3]; P1OUT = digitos[disp_4]; aguarde(TEMP); disp_1++; if(disp_1 == 10){ disp_1 = 0; disp_2++; } if(disp_2 == 10){ disp_2 = 0; disp_3++; }if(disp_3 == 10){ disp_3 = 0; disp_4++; }if(disp_4 == 10) disp_4 = 0; //}while((ler_bit(P1IN,7))||(ler_bit(P2IN,0))||(ler_bit(P2IN,1))); }while((ler_bit(P2IN,0))||(ler_bit(P2IN,1))); //break; } if(~((ler_bit(P1IN,7))||(ler_bit(P2IN,0))||(ler_bit(P2IN,1)))){ P2OUT = mudar[0];
  • 2. P1OUT = digitos[disp_1]; aguarde(TEMP); P2OUT = mudar[1]; P1OUT = digitos[disp_2]; aguarde(TEMP); P2OUT = mudar[2]; P1OUT = digitos[disp_3]; aguarde(TEMP); P2OUT = mudar[3]; P1OUT = digitos[disp_4]; aguarde(TEMP); } //Mostrar en cada digito un valor if(ler_bit(P2IN,1)){ // while(1) do{ P2OUT = mudar[0]; P1OUT = digitos[7]; aguarde(TEMP); P2OUT = mudar[1]; P1OUT = digitos[6]; aguarde(TEMP); P2OUT = mudar[2]; P1OUT = digitos[1]; aguarde(TEMP); P2OUT = mudar[3]; P1OUT = digitos[5]; aguarde(TEMP); }while((ler_bit(P1IN,7))||(ler_bit(P2IN,0))||(ler_bit(P2IN,1))); //break; } }} int ler_bit(char a, int b) { char var = (1 << b); if(var == (a & var)) return 1; else return 0; } int aguarde(long t0) { long y=0; while(y++ < t0); return 1; }