stm32 transmit radio message 433 mhz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-06-12 6:05 AM
I have on radio transmitter and one radio receiver like on the picture. What I am trying to do.
I send data through USART2 PA2 (pin2) on data transmitter. I connected usb-uart to PA2 (pin2), and looked in terminal what data is there and I saw something like this (AA 44 11 55 AA 44 22 66 AA 44 11 55 AA 44 22 66 ...).It's okay i transmit what i want.Then i connected usb-uart to PA10 (pin10), and looked in terminal, there was a lot of data but mostly of them was (AA 44 11 55 AA 44 22 66 AA 44 11 55 AA 44 22 66 ...).It's okay i receive from receiver module data that was transmitted.Then iconnected usb-uart to PA9 (pin9), and looked in terminal, there was only (AA 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 ...).The main question what I am doing wrong, why USART1 TX deformates data? How to fix this?#include ''stm32f10x.h''
#include ''stm32f10x_gpio.h''#include ''stm32f10x_rcc.h''# define SYNC 0XAA
# define RADDR 0x44# define LEDON 0x11 //switch led on command# define LEDOFF 0x22 //switch led off commandvoid Delay(void) {
volatile uint32_t i; for (i = 0; i != 100; i++) ;}void send_to_uart1(uint8_t data) { while (!(USART1 - > SR & USART_SR_TXE)) {} USART1 - > DR = data;}void send_to_uart2(uint8_t data) {
while (!(USART2 - > SR & USART_SR_TXE)); USART2 - > DR = data;}void Send_Packet(uint8_t addr, uint8_t cmd) {
send_to_uart2(SYNC); //send synchro byte send_to_uart2(addr); //send receiver address send_to_uart2(cmd); //send increment command send_to_uart2((addr + cmd)); //send checksum}uint8_t uart_data;
int main(void) {
GPIO_InitTypeDef PORTA_init_struct;RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_USART1, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);PORTA_init_struct.GPIO_Pin = GPIO_Pin_9;
PORTA_init_struct.GPIO_Speed = GPIO_Speed_2MHz; PORTA_init_struct.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, & PORTA_init_struct);PORTA_init_struct.GPIO_Pin = GPIO_Pin_10;
PORTA_init_struct.GPIO_Speed = GPIO_Speed_50MHz; PORTA_init_struct.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOA, & PORTA_init_struct);PORTA_init_struct.GPIO_Pin = GPIO_Pin_2;
PORTA_init_struct.GPIO_Speed = GPIO_Speed_50MHz; PORTA_init_struct.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, & PORTA_init_struct);PORTA_init_struct.GPIO_Pin = GPIO_Pin_3;
PORTA_init_struct.GPIO_Speed = GPIO_Speed_50MHz; PORTA_init_struct.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOA, & PORTA_init_struct);USART_InitTypeDef uart_struct1;
uart_struct1.USART_BaudRate = 600; uart_struct1.USART_WordLength = USART_WordLength_8b; uart_struct1.USART_StopBits = USART_StopBits_1; uart_struct1.USART_Parity = USART_Parity_No; uart_struct1.USART_HardwareFlowControl = USART_HardwareFlowControl_None; uart_struct1.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; USART_Init(USART1, & uart_struct1); USART_Cmd(USART1, ENABLE);USART_InitTypeDef uart_struct2;
uart_struct2.USART_BaudRate = 600; uart_struct2.USART_WordLength = USART_WordLength_8b; uart_struct2.USART_StopBits = USART_StopBits_1; uart_struct2.USART_Parity = USART_Parity_No; uart_struct2.USART_HardwareFlowControl = USART_HardwareFlowControl_None; uart_struct2.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; USART_Init(USART2, & uart_struct2); USART_Cmd(USART2, ENABLE);uint8_t raddress, data, chk;
while (1) {
Send_Packet(RADDR, LEDON); Delay(); Send_Packet(RADDR, LEDOFF); Delay();if (USART1 - > SR & USART_SR_RXNE) {
uart_data = USART1 - > DR; send_to_uart1(uart_data); }}
}- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-06-12 7:21 AM
Do you have data sheets for the receiver and transmitter pictured? Does the documentation indicate that data can be sent in this fashion, or needs to be modulated?
Use the TXE bit, not TC to determine if the USART is ready to accept new data.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-06-12 7:41 AM
I found only
http://forum.hobbycomponents.com/viewtopic.php?f=25&t=1324
and I have no any data sheets for this modules.:(
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-06-12 9:28 AM
Do you have data sheets for the receiver and transmitter pictured? Does the documentation indicate that data can be sent in this fashion, or needs to be modulated?
And not to forget, the voltage levels need to match as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-06-12 10:38 AM
These modules look familiar. I had similar toys once. If you want quality products which work, buy something else.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-06-12 11:45 PM
I think I found where is problem I'll try to describe.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-06-13 12:38 AM
Or at least a name and some specs., from a shop you bought it from ?
