Skip to main content
Ymaul.1
Associate
April 28, 2020
Question

how to interfacing Servo driver PCA9685 with STM32F103VET6

  • April 28, 2020
  • 4 replies
  • 3923 views

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

This topic has been closed for replies.

4 replies

Piranha
Principal III
April 28, 2020

And again that useless "Help! Something doesn't work"...

Do we have to pull out all the information from you?

Ymaul.1
Ymaul.1Author
Associate
April 28, 2020

yes, please

Piranha
Principal III
May 6, 2020

Thanks, no.

Tesla DeLorean
Guru
May 6, 2020

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

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Ymaul.1
Ymaul.1Author
Associate
May 11, 2020

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