Browse Source

修改波特率

dev^2
Zhangwen 1 year ago
parent
commit
3e85ea8317
  1. 54
      keilp/stcTTSS2_W5.uvprojx
  2. 2
      source/bsp/TTSSbsp/bsp_config.h
  3. 4
      source/debug/debug_drv.c
  4. 68
      source/msp/uart/msp_uart1.c

54
keilp/stcTTSS2_W5.uvprojx

@ -10,7 +10,6 @@
<TargetName>STC8H3K64S2</TargetName>
<ToolsetNumber>0x0</ToolsetNumber>
<ToolsetName>MCS-51</ToolsetName>
<uAC6>0</uAC6>
<TargetOption>
<TargetCommonOption>
<Device>STC8H3K64S4 Series</Device>
@ -124,6 +123,47 @@
<HexOffset>0</HexOffset>
<Oh166RecLen>16</Oh166RecLen>
</OPTHX>
<Simulator>
<UseSimulator>1</UseSimulator>
<LoadApplicationAtStartup>1</LoadApplicationAtStartup>
<RunToMain>1</RunToMain>
<RestoreBreakpoints>1</RestoreBreakpoints>
<RestoreWatchpoints>1</RestoreWatchpoints>
<RestoreMemoryDisplay>1</RestoreMemoryDisplay>
<RestoreFunctions>1</RestoreFunctions>
<RestoreToolbox>1</RestoreToolbox>
<LimitSpeedToRealTime>0</LimitSpeedToRealTime>
<RestoreSysVw>1</RestoreSysVw>
</Simulator>
<Target>
<UseTarget>0</UseTarget>
<LoadApplicationAtStartup>1</LoadApplicationAtStartup>
<RunToMain>0</RunToMain>
<RestoreBreakpoints>1</RestoreBreakpoints>
<RestoreWatchpoints>1</RestoreWatchpoints>
<RestoreMemoryDisplay>1</RestoreMemoryDisplay>
<RestoreFunctions>0</RestoreFunctions>
<RestoreToolbox>1</RestoreToolbox>
<RestoreTracepoints>1</RestoreTracepoints>
<RestoreSysVw>1</RestoreSysVw>
</Target>
<RunDebugAfterBuild>0</RunDebugAfterBuild>
<TargetSelection>-1</TargetSelection>
<SimDlls>
<CpuDll></CpuDll>
<CpuDllArguments></CpuDllArguments>
<PeripheralDll></PeripheralDll>
<PeripheralDllArguments></PeripheralDllArguments>
<InitializationFile></InitializationFile>
</SimDlls>
<TargetDlls>
<CpuDll></CpuDll>
<CpuDllArguments></CpuDllArguments>
<PeripheralDll></PeripheralDll>
<PeripheralDllArguments></PeripheralDllArguments>
<InitializationFile></InitializationFile>
<Driver></Driver>
</TargetDlls>
</DebugOption>
<Utilities>
<Flash1>
@ -177,14 +217,12 @@
<Mx51P>0</Mx51P>
<hadXRAM2>0</hadXRAM2>
<uocXram2>0</uocXram2>
<hadXRAM3>0</hadXRAM3>
<ModC2>0</ModC2>
<ModH2>0</ModH2>
<Mdu_R515>0</Mdu_R515>
<Mdu_F120>0</Mdu_F120>
<Psoc>0</Psoc>
<hadIROM2>0</hadIROM2>
<hadIROM3>0</hadIROM3>
<ModSmx2>0</ModSmx2>
<cBanks>0</cBanks>
<xBanks>0</xBanks>
@ -254,16 +292,6 @@
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</IROM512>
<XRA513>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</XRA513>
<IROM513>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</IROM513>
</OnChipMemories>
</Target51Misc>
<C51>

2
source/bsp/TTSSbsp/bsp_config.h

@ -166,7 +166,7 @@
//串口配置
/// #define D_UART1_BRT BRT_460800
/// #define D_UART1_BRT BRT_921600
#define D_UART1_BRT BRT_115200
#define D_UART1_BRT BRT_9600
#define D_UART1_SBIT SBIT_1
#define D_PIN_UART1 PIN_UART1_Rxd_30_Txd_31
#define D_UART2_BRT BRT_115200///BRT_921600///BRT_115200///

4
source/debug/debug_drv.c

@ -119,7 +119,7 @@ u8 L3_tpc_hex(void)
return 1;
}
}
printfs("\r\n cmd error!!");
// printfs("\r\n cmd error!!");
return 0;
}
#endif
@ -132,7 +132,7 @@ vtype L2_debug_ONcomand(void)
{
ts_Urec[D_UART1].debugok = 0;////解析协议
/// printf("\r\nw ts_Urec[D_UART1].max = %d num = %d",(int)ts_Urec[D_UART1].rmax,(int)ts_Urec[D_UART1].num);
printf1("\r\ndebugok %2x",(int)ts_Urec[D_UART1].debugok);
// printf1("\r\ndebugok %2x",(int)ts_Urec[D_UART1].debugok);
}
if(1 == ts_Urec[D_UART1].ok)

68
source/msp/uart/msp_uart1.c

@ -1,60 +1,3 @@
//////////////////////////////////////////////////////////////////////////
/// COPYRIGHT NOTICE
/// Copyright (c) 2023 CCSENS
/// All rights reserved.
///
/// @file main.c
/// @brief main app
///
///(本文件实现的功能的详述)
///
/// @version 1.1 CCsens technology
/// @author CC
/// @date 20150102
///
///
/// 修订说明:最初版本
/// Modified by:
/// Modified date:
/// Version:
/// Descriptions:
// 20160413 CC-ACC-VH02
// 连接至 J22 RXD0 TXD0
//P5_DIR &= ~BITN1; //p5.1输出TXD
//P5_DIR |= BITN0; //p5.0输入RXD
//P5_SEL0 &= ~(BITN0 +BITN1); //设置P5.0 P5.1为uart1 RXD TXD
//P5_SEL1 |= BITN0 +BITN1;
/*****************************************************************************
update by cc @201700110
.
c_lib/c_lib.c:
(线),
(lcd等固屏输出的)使
void Lc_print(void (*L0pf_send_uc)(char ww), char *dat,...)
-----------------------------------------------------------------------------------------
uartcom/Uprotocol2app
uart口来对应
typedef struct _ts_lcm_pro_; ? LCM的协议------------
L3_UARTcom0_exp_protocol
-----------------------------------------------------------------------------------------
uartcom/urec2protocol:
struct _s_uart_rec_ ()------struct _s_uart_rec_
void L1_uart_2buf(struct _s_uart_rec_ *p)
--------------------------------------------------------------------------------------------
msp/uartx.c cpu相关
L0_uart1_Init
uart1_IRQHandler
L0_Usend_uc------UserDef
-----------------------------------------------------------------------------------------
********************************************************************************/
#include "msp_uart1.h"
///#include "msp_time2.h"
#include "c_crc.h"
@ -105,6 +48,17 @@ msp/uartx.c 底层代码 和cpu相关 缓存发送也放在里面
#elif(BRT_19200 == D_UART1_BRT)
#elif(BRT_9600== D_UART1_BRT)
void L0_uart1_init(void) //9600bps@22.1184MHz
{
SCON = 0x50; //8位数据,可变波特率
AUXR |= 0x40; //定时器时钟1T模式
AUXR &= 0xFE; //串口1选择定时器1为波特率发生器
TMOD &= 0x0F; //设置定时器模式
TL1 = 0xC0; //设置定时初始值
TH1 = 0xFD; //设置定时初始值
ET1 = 0; //禁止定时器中断
TR1 = 1; //定时器1开始计时
}
#else///9600
#endif//)

Loading…
Cancel
Save