I'm using an Atmega168 I'm attempting to use I2C with my PCA9685 Servo driver.
I'm using this I2C library: https://github.com/g4lvanix/I2C-master-lib
I'm attempting to start the I2C connection with my PCA9685 (Address: 0x41).
For some reason the I2C Library is bouncing back an error because the acknowledge bit isn't being sent. What is wrong here? My SDA and SCL pins are hooked up to 10k pull up resistors, and they are connected to the PCA9685 correctly. Yet it still isn't working. Could it be my PCA9685 chip? I also know the address is 0x41 because I manually bridged an address connection to assign that address.
Here is my code:
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include <avr/power.h>
#include "i2c.h"
#define SERVO_MIN 1000
#define SERVO_MAX 2000
#define SERVO_MID 1500
#define PCA9685_ADDR 0x40
#define PCA9685_MODE1 0x0
#define LED0_ON_L 0x6
#define LED0_ON_H 0x7
#define LED0_OFF_L 0x8
#define LED0_OFF_H 0x9
#define LED PB0
#define LED_DDR DDRB
#define LED_PORT PORTB
#define DELAYTIME 200
#define setBit(sfr, bit) (_SFR_BYTE(sfr) |= (1 << bit))
#define clearBit(sfr, bit) (_SFR_BYTE(sfr) &= ~(1 << bit))
#define toggleBit(sfr, bit) (_SFR_BYTE(sfr) ^= (1 << bit))
void setupController();
void setServo(uint8_t id, uint8_t start, uint8_t stop);
int main(void)
{
setBit(LED_DDR, LED);
clock_prescale_set(clock_div_1);
i2c_init();
uint8_t err = i2c_start(0x41);
while(err == 1) {
setBit(LED_PORT, LED);
uint8_t err = i2c_start(0x41);
}
clearBit(LED_PORT, LED);
while(1) {
}
return 0;
}
Thank you in advance!