This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Serial communication

Other Parts Discussed in Thread: TMS3705, MSP430F1121

 

Hi All!

I want to get serial data byte-wise into MCU.

Is it correct to do as following:

 

#include <io430x14x.h>

#include <in430.h>

 

/*========Defines section===================================================*/

#define IN_PIN P1IN_bit.P1IN_1

 

/*========== Variables section================================================*/

unsigned char bit_num; //number of bits - 8

unsigned char buffer; //buffer for serial data

volatile struct

{

  unsigned char ser_bit: 1;

}

mybits;

 

void Get_byte(void)

{

  for ( bit_num = 7; bit_num==0; -- bit_num)

  __delay_cycles(256); //32us – bit duration is 64us – I get it in the middle

  mybits.ser_bit = IN_PIN;

  buffer |= mybits.ser_bit >>bit_num;

}

 

void main(void)

{

  cpu_init();

  while(1)

  {

    if (IN_PIN==1) //start of receiving

   Get_byte();

  }

}

 

**Attention** This is a public forum