ı will make graduation project about controlling device with dtmf using msp430...
ı wrote some codes..especially part of receiving password from user , it was very diffucult for me..I used array for password..it is 4 digits..but when ı try practically, sometimes it gives true result,but sometimes ı cant intended output.. ıwill shar my code..also ı put the timer (15 second) for not busy the line..(if user doesnt click the button)..please help me?? Also when ı try in protues, ı achieved..
#include "io430.h"
#include "in430.h"
unsigned char k,j,sifre[4]; // sifre is password in turkish
unsigned char kontrol;
int i;
void main( void )
{
WDTCTL = WDTPW + WDTHOLD;
DCOCTL=CALDCO_1MHZ;
BCSCTL1=CALBC1_1MHZ;
__delay_cycles(500000);
P1OUT = 0x00;
P1REN= BIT4 + BIT5 ;
P1DIR = 0xCF;
//basla:
_BIS_SR(GIE);
while(1){
for(k=0;k<3;k++) // this loop for that user can enter three times
{
j=0;
for(j=0;j<4;j++){ // here is for 4 digits of password
TA0CCR0=40000; // for timer (4 second) ..if user doesnt click button...
TA0CTL=TASSEL_2 + MC_1 + TAIE;
TA0CCTL0=CCIE;
while(!(P1IN & 0x30)){
if(kontrol==1)
{P1OUT_bit.P1=0;} // P1OUT_bit.P1=0; for line will close..
else{};}
TA0CTL=MC_0; i=0;
sifre[j]=(P1IN & 0x30); // take password
while((P1IN & 0x30)); // wait for releasing the button
}
if(sifre[0]==0x10 && sifre[1]==0x20 && sifre[2]==0x10 && sifre[3]==0x20 ){ // controlling of password
P1OUT_bit.P6=1;while(1){} // if password is true
}
else{sifre[0]=0x00;sifre[1]=0x00;sifre[2]=0x00;sifre[3]=0x00; // this is true??
if(k==2){P1OUT_bit.P1 = 0;break;}else{};}
}
}}
#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer_a0 (void)
{
i++;
if(i==100)
{
kontrol=1; // control=1
i=0;}
TACTL_bit.TAIFG = 0;}
Im waiting for your help...