AnsweredAssumed Answered

UART and PLM ST7540 on cortexM0

Question asked by serao.pietro on Mar 20, 2013
Latest reply on Mar 20, 2013 by Clive One
Hi guys,i'm learning about the st7540 PLM device.
My hardware configuration is the seguent:
STM32F0Discovery board and two EVALST7540-2 (st7540 transceiver).
Microcontroller--->St7540transceiver--->220V--->St7540tranceiver--->scope.

I've got an EVALCOMMBOARD too (sending with it i see the bytes on the scope correctly).

My target is to send something via UART from microcontroller an see it on the scope at the end of the communication chain.
I've read that st7540 default configuration is like that: asynchronous communication without a protocol. Reading datasheet seems that simply connecting an UART device to the transceiver, and it (the transceiver) provide the communication on 220 channel.

I've connected the sending transcinver in this way (asynchronous sending):
UART/SPI pin= 3v
RXTX, GND, REGDATA = gnd
TXD= PA9 pin

and the receiving transceiver in this way (asynchronous receiving):

UART/SPI, RXTX= 3v
GND, REGDATA = gnd
RXD= SCOPE

i use a very simple code :

/* Includes ------------------------------------------------------------------*/
#include "stm32f0xx.h"
#include "stm32f0_discovery.h"
#include "stdio.h"
 #include <string.h>


/** @addtogroup STM32F10x_StdPeriph_Examples
  * @{
  */


/** @addtogroup USART_Polling
  * @{
  */ 


/* Private typedef -----------------------------------------------------------*/
typedef enum { FAILED = 0, PASSED = !FAILED} TestStatus;


/* Private define ------------------------------------------------------------*/
#define TxBufferSize   (countof(TxBuffer))


/* Private macro -------------------------------------------------------------*/
#define countof(a)   (sizeof(a) / sizeof(*(a)))


/* Private variables ---------------------------------------------------------*/
USART_InitTypeDef USART_InitStructure;
uint8_t TxBuffer[] = "Buffer Send from USARTy to USARTz using Flags";
uint8_t RxBuffer[TxBufferSize];
__IO uint8_t TxCounter = 0, RxCounter = 0;  
volatile TestStatus TransferStatus = FAILED;  


/* Private function prototypes -----------------------------------------------*/




TestStatus Buffercmp(uint8_t* pBuffer1, uint8_t* pBuffer2, uint16_t BufferLength);
__IO uint8_t index = 0;
  
/* Private functions ---------------------------------------------------------*/
void USART_Configuration(void);
void USART2_Configuration(void);
GPIO_InitTypeDef    GPIO_InitStructure; 


/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f10x_xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f10x.c file
     */     
      
  USART_Configuration();
  
  while (1)
  { 
   
     while(TxCounter < TxBufferSize)
  {   
    /* Send one byte from USART1 */
    USART_SendData(USART1, TxBuffer[TxCounter++]);
  
    /* Loop until USART1 DR register is empty */ 
    while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET)
    {
    }
    
    /* Loop until the USARTz Receive Data Register is not empty */


    
  } 
  TxCounter=0;






  
  }
}








/**
  * @brief Configura l'USART 
  * @param  None
  * @retval None
  */
 void USART_Configuration(void)

  
  /* Abilita clock GPIOA e DMA  */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA , ENABLE);
  
  /* Abilita clock USART1 APB  */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
  
  NVIC_InitTypeDef NVIC_InitStructure;
  
  /* configurazione pin USART1   **************************************************/
 // GPIO_DeInit(GPIOA);
  
  /* Connette i pin PA9 e PA10 alla periferica USART */
  GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_1);    
  GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_1); 
  
  /* Configura i pin come AF pushpull */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10 ;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_2;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
  GPIO_Init(GPIOA, &GPIO_InitStructure); 


  
  /* Configurazione USART1:
  - BaudRate = 115200 baud  
  - Word Length = 8 Bits
  - Stop Bit = 1 Stop Bit
  - Parity = No Parity
  - Hardware flow control disabled (RTS and CTS signals)
  - Receive and transmit enabled
  */
   
  USART_DeInit(USART1);
  USART_InitStructure.USART_BaudRate = 4800;
  USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  USART_InitStructure.USART_StopBits = USART_StopBits_1;
  USART_InitStructure.USART_Parity = USART_Parity_No;
  USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
  USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
  USART_Init(USART1, &USART_InitStructure);
  USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); // enable the USART2 receive interrupt
 
        NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;                // we want to configure the USART2 interrupts
        NVIC_InitStructure.NVIC_IRQChannelPriority = 0;// this sets the priority group of the USART2 interrupts
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;                  // the USART2 interrupts are globally enabled
        NVIC_Init(&NVIC_InitStructure);          
  
  USART_Cmd(USART1, ENABLE); 
}


CAN SOMEONE HELP ME, PLEASE ???

Outcomes