PWM如何操作以及无法调用sprintf函数功能
-
1、需求为3个PWM输出,每个PWM输出通道都是不同的,频率也不同,占空比也不同属于独立配置
按照贵司的建议这样配置,只有第一个通过工作,其他都不工作,不知哪里出了问题
#define ETMR_INST 0
#define ETMR_INST1 1
#define ETMR_INST2 2eTMR_DRV_Init(ETMR_INST,&ETMR_CM_Config0,&ETMR_CM_Config0_State);
eTMR_DRV_InitPwm(ETMR_INST,&ETMR_PWM_Config0);
eTMR_DRV_Enable(ETMR_INST);eTMR_DRV_Init(ETMR_INST1,&ETMR_CM_Config1,&ETMR_CM_Config1_State);
eTMR_DRV_InitPwm(ETMR_INST1,&ETMR_PWM_Config1);
eTMR_DRV_Enable(ETMR_INST1);eTMR_DRV_Init(ETMR_INST2,&ETMR_CM_Config2,&ETMR_CM_Config2_State);
eTMR_DRV_InitPwm(ETMR_INST2,&ETMR_PWM_Config2);
eTMR_DRV_Enable(ETMR_INST2);2、因为采用了贵司的框架去开发程序,由于自己搭建的工程,两个串口都需要工作,所以没有用贵司的中间件PRINT这个功能,导致现在开发字符串处理,无法开展,显示加载《stdio.h》报错,不知如何解决。应用中主要就是调用sprintf这个接口。
//sprintf(str,"p0t2.txt="%4.2f"\xff\xff\xff", (float)(Uart_Senser_data.concentration)/10);
3、针对SPI接口,芯片是主机,配置如下,现在就是与TI芯片DRV8889,手册见附件,在通信过程中就是不能将数据写入对方芯片,不知应该如何配置。芯片数据位16位,寄存器也是按照对方的芯片编写,通过示波器看,数据也出来,但是就是数据转化这边出问题。不知贵司是否有成功读取TI芯片SPI接口的相关案例。SPI_DRV_MasterInit(SPI_MASTER_INST,&spi_MasterConfig0_State,&spi_MasterConfig0);
spi_state_t spi_MasterConfig0_State;
const spi_master_config_t spi_MasterConfig0 = {
.bitsPerSec=100000U,
.whichPcs=SPI_PCS0,
.pcsPolarity=SPI_ACTIVE_LOW,
.isPcsContinuous=false,
.bitcount=16,
.clkPhase=SPI_CLOCK_PHASE_2ND_EDGE,
.clkPolarity=SPI_SCK_ACTIVE_HIGH,
.lsbFirst=true,
.transferType=SPI_USING_INTERRUPTS,
.rxDMAChannel=0,
.txDMAChannel=0,
.callback=NULL,
.callbackParam=NULL,
.width=SPI_SINGLE_BIT_XFER,
};#define SPI_MASTER_INST (1)
#define SPI_TRANS_LENGTH1 (2)
#define ReadSPI 0x40
#define WRSPI 0x00void WriteReg_DRV8889(unsigned char Data,unsigned char addr)
{
unsigned short count_wr=0;masterTxBuff1[1]=addr*2;
masterTxBuff1[0]=Data;
SPI_DRV_MasterTransfer(SPI_MASTER_INST, masterTxBuff1, masterRxBuff1, SPI_TRANS_LENGTH1);while (STATUS_SUCCESS != SPI_DRV_MasterGetTransferStatus(SPI_MASTER_INST, NULL))
{
OSIF_TimeDelay(1);
if (count_wr > TIMEOUT)
{
spiError = true;
}
else
{
count_wr=count_wr+1;}
}
count_wr = 0;}
unsigned short ReadReg_DRV8889(unsigned char addr)
{
unsigned short count_wr=0;
unsigned short DATA;masterTxBuff1[1]=ReadSPI+(addr<<1);
masterTxBuff1[0]=0x00;
SPI_DRV_MasterTransfer(SPI_MASTER_INST, masterTxBuff1, masterRxBuff1, SPI_TRANS_LENGTH1);
DATA = ((unsigned short)masterRxBuff1[0]<<8) + (unsigned short)masterRxBuff1[1];while (STATUS_SUCCESS != SPI_DRV_MasterGetTransferStatus(SPI_MASTER_INST, NULL))
{
OSIF_TimeDelay(1);
if (count_wr > TIMEOUT)
{
spiError = true;
}
else
{
count_wr=count_wr+1;}
}
count_wr = 0;
return DATA;
} -
-
检查下pin配置;
-
要看使用的IDE;
-
模式01,MSB,配置没问题,参考下面24bit通信:uint32_t receive =0;
uint32_t command;command = (sendData[0]<<16) + (sendData[1]<<8) + sendData[2];
LPSPI2_transmit_24bits(command);receive= LPSPI2_receive_24bits();
receiveData[0] = receive >> 16u;
receiveData[1] = receive >> 8u;
receiveData[2] = (uint8_t)(receive);
-
快速上手云途开发生态
发帖前请查看
帮助改进和优化YT CONFIG TOOL,有机会抽取YTM32B1ME0 EVB哦...