Jump to content
Sign in to follow this  
trungkiena6

[TLC59116F] Problems with it

Recommended Posts

Hello everyone. i have a project with TLC59116F, but my project can't run. It is my code.

P/s: Thanks aBUGSworstnightmare with I2C API

 
 
 
/******************************************************************************
 *
 * Module : TLC59116F_TEST
 * Description : TLC59116F
 *  Tool : KEIL
 * Chip : Stellaris
 *  History : 
 *  Version      : 
 *
 * Author : BTK
 * Notes : None, 
 *
 *****************************************************************************/
 
/******************************************************************************
 * IMPORT
 *****************************************************************************/
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
 
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
#include "driverlib/i2c_Stellaris.h"
#include "driverlib/adc.h"
 
#include "utils/uartstdio.h"
/* Thanh ghi chuc nang cua TLC59116*/
#define MODE1 0x00
#define MODE2 0x01
#define PWM0 0x02
#define PWM1 0x03
#define PWM2 0x04
#define PWM3 0x05
#define PWM4 0x06
#define PWM5 0x07
#define PWM6 0x08
#define PWM7 0x09
#define PWM8 0x0A
#define PWM9 0x0B
#define PWM10 0x0C
#define PWM11 0x0D
#define PWM12 0x0E
#define PWM13 0x0F
#define PWM14 0x10
#define PWM15 0x11
#define GPPWM  0x12
#define GFREQ  0x13
#define LEDOUT0 0x14
#define LEDOUT1 0x15
#define LEDOUT2 0x16
#define LEDOUT3 0x17
#define SUBADR1 0x18
#define SUBADR2 0x19
#define SUBADR3 0x1A
#define ALLCALLADR 0x1B
/*----------------------------------------------------------------------------*/
#define RESET GPIO_PIN_6
#define ADDRESS 0x68
/******************************************************************************
 * EXTERN
 *****************************************************************************/
void InitConsole(void);
void Delay_ms(unsigned long ulTime);
void Delay_us(unsigned long ulTime);
void Delay_s(unsigned long ulTime);
/******************************************************************************
 * GLOBAL VARIABLE
 *****************************************************************************/
 
 
/******************************************************************************
 * ROUTINES
 *****************************************************************************/
 /* Khoi dong UART */
void InitConsole(void)
{
    
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinConfigure(GPIO_PA0_U0RX);
    GPIOPinConfigure(GPIO_PA1_U0TX);
    GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    UARTStdioInit(0);
}
/* Make Delay */
void Delay_ms(unsigned long ulTime){
SysCtlDelay(SysCtlClockGet()/(3000*ulTime));
}
void Delay_us(unsigned long ulTime){
SysCtlDelay(SysCtlClockGet()/(3*1000000*ulTime));
}
void Delay_s(unsigned long ulTime){
SysCtlDelay(SysCtlClockGet()/(3*ulTime));
}
 
/******************************************************************************
 * MAIN
 *****************************************************************************/
int main(void)
{ 
    SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |SYSCTL_XTAL_16MHZ);
InitConsole();
GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE,RESET);
GPIOPinWrite(GPIO_PORTA_BASE,RESET,0x40);
I2CSetup(I2C0_MASTER_BASE,true);
I2CBusScan(I2C0_MASTER_BASE);
 
I2CRegWrite(I2C0_MASTER_BASE,ADDRESS,PWM0,0xAA);
Delay_s(1);
I2CRegWrite(I2C0_MASTER_BASE,ADDRESS,PWM0,0x00);
Delay_s(1);
while(1){
 
 
 
}
 
}
/******************************************************************************
 * END OF .c
 *****************************************************************************/

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×