Tool/software:
Hi, I'm using this code in CCS with F280025c to write UVLO1 level in config1 register. But thd moment i am running the code, nFLT2 goes low. what i feel is somehow adressing is wrong but i am unable to figure where.
I am first setting the register by WR_RA command given in datasheet table 7-3 then changing lower bits WRL. Please help
This is my code:
//UCC5870-Q1 Configuration using TI F280025C
#include "F28002x_Device.h" // Include F280025C header file
#include "driverlib.h" // Include TI driver library
#include "device.h" // Include device-specific definitions
// Define SPI settings
#define SPI_BAUD_RATE 1000000 // 1 MHz
#define SPI_CLK_POLARITY 0 // Clock polarity
#define SPI_CLK_PHASE 1 // Clock phase
// Define GPIO pins for SPI on LaunchPad
#define SPI_CS_PIN 10 // Chip select (use GPIO10)
#define SPI_MISO_PIN GPIO_17_SPIA_SOMI // SDO (use GPIO17)
#define SPI_MOSI_PIN GPIO_16_SPIA_SIMO // SDI (use GPIO16)
#define SPI_CLK_PIN GPIO_9_SPIA_CLK
// Define CHIP Address
#define CHIP_ADDR 0x0 // Default chip address
volatile uint8_t faultDetected = 0;
// Function prototypes
void setupSPI(void);
void writeUCC5870(uint16_t regAddr, uint16_t data);
uint16_t readUCC5870(uint16_t regAddr);
void configureUCC5870(void);
void checkFaultStatus(void);
void enterConfiguration2(void);
void exitConfiguration2(void);
void main(void) {
// Initialize device
Device_init();
Device_initGPIO();
// Setup SPI
setupSPI();
// Configure UCC5870
configureUCC5870();
while(1) {
// Main loop
}
}
void setupSPI(void) {
// Configure GPIO pins for SPI on LaunchPad
GPIO_setPinConfig(SPI_MOSI_PIN); // Configure MOSI
GPIO_setPinConfig(SPI_MISO_PIN); // Configure MISO
GPIO_setPinConfig(SPI_CLK_PIN); // Configure CLK
GPIO_setPinConfig(GPIO_10_GPIO10);
GPIO_setDirectionMode(SPI_CS_PIN, GPIO_DIR_MODE_OUT); // Set CS as output
// Configure SPI
SPI_setConfig(SPIA_BASE, DEVICE_LSPCLK_FREQ, SPI_PROT_POL0PHA1, SPI_MODE_MASTER, SPI_BAUD_RATE, 16);
SPI_enableModule(SPIA_BASE);
SPI_setEmulationMode(SPIA_BASE, SPI_EMULATION_FREE_RUN);
}
void writeUCC5870(uint16_t regAddr, uint16_t data)
{
GPIO_writePin(SPI_CS_PIN, 0); // Pull CS low
// Step 1: Set Register Address using WR_RA (0xC)
uint16_t command;
command = (CHIP_ADDR << 12) | (0xC << 8) | (regAddr & 0x1F);
SPI_writeDataBlockingNonFIFO(SPIA_BASE, command);
DEVICE_DELAY_US(10);
// Step 2: Write Data using WRL (0xB)
uint16_t txData = ((CHIP_ADDR << 12) | (0xB << 8) | (data & 0xFF));
SPI_writeDataBlockingNonFIFO(SPIA_BASE, txData);
while(SPI_isBusy(SPIA_BASE));
GPIO_writePin(SPI_CS_PIN, 1); // Release CS
}
void configureUCC5870(void) {
// Configure UVLO1 (register address 0x00) with value 0x00
writeUCC5870(0x00, 0x00);
}
This is what i am seeing on oscilloscope (RED- nCS, Blue - CLK, black - SDI)