2437 views|1 replies

1w

Posts

204

Resources
The OP
 

Application Development Notes | Mir MYD-YA15XC-T LoRa Wireless Communication Example [Copy link]

1. Overview

This article mainly describes the debugging process of M4 core LoRa based on the Raspberry Pi expansion board of the wireless serial port module with LoRa modulation function.

2. Hardware resources

Typec Debug cable 1

Micro usb cable 1

MYD-15XC-T development board

2 SX1262 868M LoRa HAT modules for Raspberry Pi interface

3. Software Resources

Linux 5.4.31

STM32CubeIDE 1.5.0

Linux virtual machine

SDK provided by Mir

4. Environmental Preparation

Install CubeIDE and other development software in advance and build the Linux virtual machine environment. For specific environment construction, please refer to Mir's software development manual "MYD-YA15XC-T_Linux Software Development Guide".

5. Operation steps

5.1. Hardware Introduction and Setup

1) Hardware Introduction

For the hardware introduction and settings of the Raspberry Pi interface SX1262 868M LoRa HAT module, please refer to the Weixue official website:

https://www.waveshare.net/wiki/SX1262_868M_LoRa_HAT

2) Wiring and settings

Two LoRa modules are needed. One LoRa module is connected to the PC via Micro USB, the jumper is set to A, M1 and M0 are connected to GND, and the SSCOM serial port software is opened to connect the LoRa module. The jumper of the other LoRa module is connected to B, and the M0 and M1 jumpers are removed and used instead of the GPIO of the MYD-YA15XC-T development board, as shown in the following figure:

Figure 5-1. Connection and configuration

5.2. CubeMX Configuration

Set the clock to 209M. As shown in the figure below, just enter 209M in the red box and press "Enter". The clock parameters will be automatically set:

Figure 5-1. Clock Settings

Since the module communication interface uses a serial port, it is also necessary to set the usart peripheral and enable interrupts:

Figure 5-2. Serial port settings

Then check the serial port interrupt and send and receive through the interrupt:

Figure 5-3. Serial port interrupt

5.3. Software Design

After generating the code in Section 5.2, create a new "LoRa" directory in the project directory to store the LoRa configuration code (the module setting source code is available on the Weixue official website, and users can directly transplant it):

Set the register configuration mode. Here you first need to set mode 2 for register configuration:

void cfg_sx126x_io(uint8_t status)

{

if(CFG_REGISTER == status){

M0_RESET();

M1_SET();

HAL_Delay(5);

}else if(NORMAL_STATUS == status){

M0_RESET();

M1_RESET();

HAL_Delay(5);

}else if(WOR_STATUS == status){

M0_SET();

M1_RESET();

HAL_Delay(5);

}else if(SLEEP_STATUS == status){

M0_SET();

M1_SET();

HAL_Delay(5);

}

}

Configure registers, set baud rate to 9600, broadcast listening address:

/******************************************************************************

sx126x mode :broadcast & monitor mode

parameter:

address_high:0xff

address_low:0xff

net_id: 0x00

serial:0x62

power: 0x00

channel: 0x12

transmission_mode: 0x03

crypt_high: 0x00

crypt_low: 0x00

******************************************************************************/

lora_para_t transparent_mode = {

.address_high =BROADCAST_ADDH_VALUE,

.address_low =BROADCAST_ADDL_VALUE,

.net_id =BROADCAST_NETID_VALUE,

.serial =BROADCAST_SERIAL_VALUE,

.power =BROADCAST_POWER_VALUE,

.channel =BROADCAST_CHANNEL_VALUE,

.transmission_mode =BROADCAST_TRANSIMISSION_VALUE,

.crypt_high =BROADCAST_CRYPTH_VALUE,

.crypt_low =BROADCAST_CRYPTL_VALUE

};

Setting registers:

uint8_t sx126x_write_register(lora_para_t para)

{

int8_t i;

buffer[0] = CFG_HEADER;

buffer[1] = REG_START;

buffer[2] = REG_NUMBER;

for(i=3;i<12;i++){

buffer = *(.address_high + i - 3);

}

HAL_UART_Transmit_IT(&huart3,(uint8_t *)buffer,12);

HAL_UART_Receive_IT(&huart3,(uint8_t *)buffer,12);

HAL_Delay(500);

if(CFG_RETURN == buffer[0]){

buffer[0] = 0;

init_cplt_flag = SUCCESS;

return SUCCESS;

}

return ERROR;

}

Define the information to be sent:

/* USER CODE BEGIN 1 */

uint8_t transparent_string[] = "Helloworld";//"This is a transparent message\r\n";

uint32_t delay;

/* USER CODE END 1 */

In the main function, use the serial port interrupt to send and receive:

/* Infinite loop */

/* USER CODE BEGIN WHILE */

while (1)

{

/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */

if(delay++>18000000){

HAL_UART_Transmit_IT(&huart3,transparent_string,strlen((const char *)transparent_string));

delay = 0;

}

if(SUCCESS == over_flag){

HAL_UART_Transmit_IT(&huart3,buffer,strlen((const char *)buffer));

over_flag = ERROR;

rece_count = 0;

HAL_UART_Receive_IT(&huart3,(uint8_t *)&rece_buff,1);

}

}

Testing

1) Start the m4 firmware in mass production mode

Start the development board and start the m4 firmware as follows:

root@myir-ya151c-t-4e512d:~# cp LoRa_CM4.elf /lib/firmware/

root@myir-ya151c-t-4e512d:~# echo LoRa_CM4.elf > /sys/class/remoteproc/remotepro

c0/firmware

root@myir-ya151c-t-4e512d:~# echo start > /sys/class/remoteproc/remoteproc0/stat

and

[ 82.845983] remoteproc remoteproc0: powering up m4

[ 82.859219] remoteproc remoteproc0: Booting fw image LoRa_CM4.elf, size 2532532

[ 82.865319] remoteproc remoteproc0: header-less resource table

[ 82.870883] remoteproc remoteproc0: no resource table found for this firmware

[ 82.884297] remoteproc remoteproc0: header-less resource table

[ 82.888689] remoteproc remoteproc0: remote processor m4 is now up

2) Information Reception

Open sscom, you can see that the USB-controlled LoRa module can receive data, as shown in the following figure:

Figure 5-2. Data Receiving

This post is from Embedded System
Add and join groups EEWorld service account EEWorld subscription account Automotive development circle

Latest reply

Awesome!   Details Published on 2021-9-30 21:12
Personal signature

玩板看这里:

http://en.eeworld.com/bbs/elecplay.html

EEWorld测评频道众多好板等你来玩,还可以来频道许愿树许愿说说你想要玩的板子,我们都在努力为大家实现!


1412

Posts

3

Resources
2
 

Awesome!

This post is from Embedded System
 
Personal signature

没有什么不可以,我就是我,不一样的烟火! 

 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list