Serial Communication

PC and the controller can perform serial communication.

 

Things to Prepare

CM-530 PC connection status

The communication speed of the example is set to 57600bps.

 

Theory

Serial communication is the basic method to show the value of the controller to users by transmitting to PC. You can try serial communication with the controller through this example.

The microcontroller and PC comm are in USART channel 3

Refer to controller’s port for port and pin number in  03 SERIAL COMMUNICATION\APP\src\main.c

 

Source

int main(void)

{

/* System Clocks Configuration */

RCC_Configuration();

/* NVIC configuration */

NVIC_Configuration();

/* Configure the GPIO ports */

GPIO_Configuration();

/* USART Configuration */

USART_Configuration(57600);

GPIO_ResetBits(PORT_LED_POWER, PIN_LED_POWER);

 

while(1)

{

ReceivedData = RxDByte_PC();

if(ReceivedData == 'w')

TxDString("Welcome!\r\n");

else if(ReceivedData == 'g')

TxDString("Goodbye!\r\n");

}

      return 0;

}

 

 

Result

Press the w for welcome and g key for goodbye.

serial_communication_result.png