Quantcast
Channel: Microcontrollers
Viewing all articles
Browse latest Browse all 218316

Forum Post: MSP430G2553: MSP430 simple IR communication

$
0
0
Part Number: MSP430G2553 Hi everyone.I am begginer at MSP430.; I would like to bliknk two different leds via pressing two different buttons using IR. I think transmitter works propperly.But something is wrong with my receiver. RX: #include void init(void); void configClock(void); void configTimer(void); void startTimer(void); void stopTimer(void); void clearTimer(void); unsigned int readTimer(void); void listen_IR(void); unsigned int time_in_low; unsigned int time_in_high; int A; int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer P1DIR = BIT0|BIT6; P1REN = BIT3; P1OUT = BIT3; init(); while(1) { listen_IR(); } } void listen_IR(void) { if((P1IN & BIT3)!=BIT3) { //falling edge startTimer();} if((P1IN & BIT3)==BIT3){ //rising edge stopTimer(); A=readTimer(); //read the timer to detect PWM length clearTimer(); } if (A>8000 && A 3000 && A void init(void); void configClock(void); void configTimer(void); void startTimer(void); void stopTimer(void); void clearTimer(void); unsigned int readTimer(void); void listen_IR(void); int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer BCSCTL1 = CALBC1_1MHZ; // Set range DCOCTL = CALDCO_1MHZ; P1DIR = 0x00; P1REN= 0xFF; P2DIR = BIT0; P2OUT=0x00; int i; while(1) { if (!(P1IN & 0x08)) { for(i=0;i<692;i++){ // 38kHz, 9ms %50 dutycycle PWM signal period=26us P2OUT^=0x01; __delay_cycles(10); } } if (!(P1IN & 0x01) ){ for(i=0;i<381;i++){ //38kHz, 9ms %50 dutycycle PWM signal, period=26us P2OUT^=0x01; __delay_cycles(10); } } } }

Viewing all articles
Browse latest Browse all 218316

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>