Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

TX RX test code in CMSIS style simplisity studio

Status
Not open for further replies.

yefj

Advanced Member level 4
Joined
Sep 12, 2019
Messages
1,215
Helped
1
Reputation
2
Reaction score
3
Trophy points
38
Activity points
7,282
Hello I have build bellow the basic stuff of UART initialization .
Now i need to do the operations with sending and receiving DATA registers.

regarding sending the data:

I need to make sure the TXS flag in USARTn_STATUS register is SET,also we use TXDATA register which table shown bellow.

So using CMSIS style writing,but i am not sure regaring two things:
1.how exactly should i define the inverted bitmask that uses to clear the old TXDATA
2.how do i define the binary 5 and in the send register.

Code:
if (USART_STATUS_TXC==0) /* Transmition has not started yet */
{
USART0->TXDATA=(USAT0->TXDATA&~_USART_STATUS_TXDATA_MASK)|0b0101) /*send binary 5 from Tx */
USART0->STATUS=(USAT0->STATUS&~_USART_STATUS_TXC_MASK)|USART_STATUS_TXC) /*Transmition finished*/
}

Code:
#include "em_device.h"
#include "em_cmu.h"
#include "em_gpio.h"
#include "em_usart.h"
#include "em_chip.h"

#define BUFFER_SIZE 80
char buffer[BUFFER_SIZE];

/**************************************************************************//**
* @brief  Main function
*****************************************************************************/
int main(void)
{
  USART_InitAsync_TypeDef init = USART_INITASYNC_DEFAULT;
  char welcome_string[] = "Silicon Labs UART Code example!\r\f";
  int i,j;

  // Chip errata
  CHIP_Init();

  // Enable oscillator to GPIO and USART1 modules
  CMU_ClockEnable(cmuClock_GPIO, true);
  CMU_ClockEnable(cmuClock_USART0, true);

  // set pin modes for UART TX and RX pins
  GPIO_PinModeSet(gpioPortC, 1, gpioModeInput, 0);
  GPIO_PinModeSet(gpioPortC, 0, gpioModePushPull, 1);

  // Initialize USART asynchronous mode and route pins
  USART_InitAsync(USART0, &init);
  USART0->ROUTE |= USART_ROUTE_TXPEN | USART_ROUTE_RXPEN;
  if (USART_STATUS_TXC==0) /* Transmition has not started yet */
{
USART0->TXDATA=(USAT0->TXDATA&~_USART_STATUS_TXDATA_MASK)|0b0101) /*send binary 5 from Tx */
USART0->STATUS=(USAT0->STATUS&~_USART_STATUS_TXC_MASK)|USART_STATUS_TXC) /*Transmition finished*/
}

1.JPG

2.JPG

3.JPG

4.JPG
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top