你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

stm32f103c8t6串口发送大量hex数据失效。

[复制链接]
Lanthanesthai. 提问时间:2024-5-2 16:43 / 未解决
我发送数据量为640个十六进制数据是正常的,上位机有收到书籍。但是我想发送3600个数据就一直灭有反应,不知道为啥什么,求助。我使用的是A9,A10的usart接口。以下是部分代码
#include "stm32f10x.h"                  // Device header
#include <stdio.h>
#include <stdarg.h>


void Serial_Init(void)
{
        RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
        RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
       
        GPIO_InitTypeDef GPIO_InitStructure;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_Init(GPIOA, &GPIO_InitStructure);
       
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_Init(GPIOA, &GPIO_InitStructure);
       
        USART_InitTypeDef USART_InitStructure;
        USART_InitStructure.USART_BaudRate = 9600;
        USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
        USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
        USART_InitStructure.USART_Parity = USART_Parity_No;
        USART_InitStructure.USART_StopBits = USART_StopBits_1;
        USART_InitStructure.USART_WordLength = USART_WordLength_8b;
        USART_Init(USART1, &USART_InitStructure);
       
        USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
       
        NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
       
        NVIC_InitTypeDef NVIC_InitStructure;
        NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
        NVIC_Init(&NVIC_InitStructure);
       
        USART_Cmd(USART1, ENABLE);
}

void Serial_SendByte(uint8_t Byte)
{
        USART_SendData(USART1, Byte);
        while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
}

void Serial_SendArray(uint8_t *Array, uint16_t Length)
{
        uint16_t i;
        for (i = 0; i < Length; i ++)
        {
                Serial_SendByte(Array[i]);
        }
}


然后我定义了一个数组arra[3600],用 Serial_SendArray函数发送后没有反应
收藏 1 评论3 发布时间:2024-5-2 16:43

举报

3个回答
wtliu 回答时间:2024-5-2 17:15:43

BootLoader 上用的

Lanthanesthai. 回答时间:2024-5-2 17:59:07

wtliu 发表于 2024-5-2 17:15
BootLoader 上用的

我都是接0

xmshao 回答时间:2024-5-6 10:58:13
从你的描述来看,说明发送相关的软硬件没多少问题,会不会是堆\栈方面的问题呢?相应调整下试试。
关于意法半导体
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
招聘信息
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
关注我们
st-img 微信公众号
st-img 手机版