2020-04-28 02:16 AM
hello I'm new with STM32 arm processor, usually I'm using arduino board for programming. now I'm trying to interfacing PCA9685 module with STM32F103VET6 and still not works. please, can anyone help me on this project, It will help me so much. I'm using keil 5 for IDE and stm32 peripheral library. I'm attach my code here.
regards
2020-04-28 03:33 AM
And again that useless "Help! Something doesn't work"...
Do we have to pull out all the information from you?
2020-04-28 05:59 AM
yes, please
2020-05-06 02:15 PM
Thanks, no.
2020-05-06 02:26 PM
Do you have a scope?
Does the device acknowledge it's address selection?
#define PCA9685_ADDRESS (0x70 << 1) // High order 7-bits are address on STM32
2020-05-10 08:15 PM
thanks clive1
thats right, I write the address #define PCA9685_ADDRESS (0x40 << 1) (default address PCA9685 0x40) It works, the PCA9685 can communicate with STM32
but I have a problem with my source that using Std Periph library code when I running subrutine program SetPWM(u8 num, u16 on, u16 off) :
#define LED0_ON_L 0x60
#define LED0_ON_H 0x70
#define LED0_OFF_L 0x80
#define LED0_OFF_H 0x90
void SetPWM(u8 num, u16 on, u16 off)
{
PCA9685_Write(LED0_ON_L + (4*num),on);
PCA9685_Write(LED0_ON_H + (4*num),on>>8);
PCA9685_Write(LED0_OFF_L + (4*num),off);
PCA9685_Write(LED0_OFF_H + (4*num),off>>8);
}
void PCA9685_Write(unsigned char reg, unsigned char data)
{
I2C_start(I2C2,PCA9685_adrr,I2C_Direction_Transmitter);
I2C_transmit(I2C2, reg);
I2C_transmit(I2C2, data);
I2C_stop(I2C2);
}
error when I2C_transmit(I2C2, reg)
but when I using HAL library to excute the program it works (pca9685_set_channel_pwm_times(&handle,u8 num, u16 on, u16 off) on the HAL library is same with SetPWM(u8 num, u16 on, u16 off) on the Std periph library ). I don't know what to do ?
I'm attach my code here
regards