Quantcast
Channel: Motor drivers forum - Recent Threads
Viewing all articles
Browse latest Browse all 21644

Intefacing EK-TM4C123GXL with DRV8305 Evaluation Board

$
0
0
We are facing some issues while interfacing DRV8305 with EK-TM4C123GXL board.
​We have interfaced this with SPI on ​EK-TM4C123GXL board with single PWM operation mode of DRV8305. but we are not getting the desired output. The BLDC Motor is not rotating.
I am attaching the code herewith:
//*****************************************************************************
//
// project0.c - Example to demonstrate minimal TivaWare setup
//
// Copyright (c) 2012-2015 Texas Instruments Incorporated.  All rights reserved.
// Software License Agreement
// 
// Texas Instruments (TI) is supplying this software for use solely and
// exclusively on TI's microcontroller products. The software is owned by
// TI and/or its suppliers, and is protected under applicable copyright
// laws. You may not combine this software with "viral" open-source
// software in order to form a larger program.
// 
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES, FOR ANY REASON WHATSOEVER.
// 
// This is part of revision 2.1.1.71 of the EK-TM4C123GXL Firmware Package.
//
//*****************************************************************************

#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/ssi.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"

//*****************************************************************************
//
// Define pin to LED color mapping.
//
//*****************************************************************************

#define RED_LED   GPIO_PIN_1
#define BLUE_LED  GPIO_PIN_2
#define GREEN_LED GPIO_PIN_3

//*****************************************************************************
//
// GPIO for PWM Generation for BLDC Motor Driver
//
//*****************************************************************************
#define INHA     GPIO_PIN_0
#define INLA     GPIO_PIN_1
#define INHB     GPIO_PIN_2
#define INLB     GPIO_PIN_3
#define INHC     GPIO_PIN_4
#define SPI_CS   GPIO_PIN_5


//*****************************************************************************
//
// The error routine that is called if the driver library encounters an error.
//
//*****************************************************************************
#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif

//*****************************************************************************
//
// Main 'C' Language entry point.  Toggle an LED using TivaWare.
// See www.ti.com/.../project0 for more information and
// tutorial videos.
//
//*****************************************************************************
uint8_t ui8_BLDC_State = 0 ;


int
main(void)
{
    //
    // Setup the system clock to run at 50 Mhz from PLL with crystal reference
    //
    SysCtlClockSet(SYSCTL_SYSDIV_1|SYSCTL_USE_OSC|SYSCTL_XTAL_16MHZ|
                    SYSCTL_OSC_MAIN);

    //
    // Enable and configure the GPIO port for the LED operation.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, RED_LED|BLUE_LED|GREEN_LED);

    //
    // Enable and configure the GPIO port for the LED operation.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, INHA|INLA|INHB|INLB|INHC|SPI_CS);

    //
    //Enable SSI0
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    GPIOPinConfigure(GPIO_PA2_SSI0CLK);
    GPIOPinConfigure(GPIO_PA3_SSI0FSS);
    GPIOPinConfigure(GPIO_PA4_SSI0RX);
    GPIOPinConfigure(GPIO_PA5_SSI0TX);

    GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_5 | GPIO_PIN_4 | GPIO_PIN_3 |
                     GPIO_PIN_2);

    SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0,
                           SSI_MODE_MASTER, 100000, 8);
    //
    // Enable the SSI0 module.
    //
    SSIEnable(SSI0_BASE);

    //
    //Send Data on SSI
    //
    GPIOPinWrite(GPIO_PORTB_BASE,SPI_CS, SPI_CS);
    GPIOPinWrite(GPIO_PORTB_BASE,SPI_CS, 0x00);
    SysCtlDelay(100);
    SSIDataPut(SSI0_BASE,0x16);
    SSIDataPut(SSI0_BASE,0x3D);
    SysCtlDelay(100);
    GPIOPinWrite(GPIO_PORTB_BASE,SPI_CS, SPI_CS);
    //
    // Loop Forever
    //
    while(1)
    {


		GPIOPinWrite(GPIO_PORTF_BASE,INHA,INHA);
		SysCtlDelay(10);
		ui8_BLDC_State++;
		if(ui8_BLDC_State>12)
		{
			ui8_BLDC_State = 1;
		}
        switch(ui8_BLDC_State)
        {
        case 1:
        	GPIOPinWrite(GPIO_PORTB_BASE,INLA ,0x00 );
        	GPIOPinWrite(GPIO_PORTB_BASE,INHB ,INHB );
        	GPIOPinWrite(GPIO_PORTB_BASE,INLB ,INLB );
        	GPIOPinWrite(GPIO_PORTB_BASE,INHC ,0x00 );
        	break;
        case 2:
        	GPIOPinWrite(GPIO_PORTB_BASE,INLA ,0x00 );
        	GPIOPinWrite(GPIO_PORTB_BASE,INHB ,INHB );
        	GPIOPinWrite(GPIO_PORTB_BASE,INLB ,0x00 );
        	GPIOPinWrite(GPIO_PORTB_BASE,INHC ,INHC );
        	break;
        case 3:
        	GPIOPinWrite(GPIO_PORTB_BASE,INLA ,0x00 );
        	GPIOPinWrite(GPIO_PORTB_BASE,INHB ,INHB );
        	GPIOPinWrite(GPIO_PORTB_BASE,INLB ,0x00 );
        	GPIOPinWrite(GPIO_PORTB_BASE,INHC ,0x00 );
        	break;
        case 4:
        	GPIOPinWrite(GPIO_PORTB_BASE,INLA ,INLA );
        	GPIOPinWrite(GPIO_PORTB_BASE,INHB ,INHB );
        	GPIOPinWrite(GPIO_PORTB_BASE,INLB ,0x00 );
        	GPIOPinWrite(GPIO_PORTB_BASE,INHC ,INHC );
        	break;
        case 5:
        	GPIOPinWrite(GPIO_PORTB_BASE,INLA ,INLA );
        	GPIOPinWrite(GPIO_PORTB_BASE,INHB ,INHB );
        	GPIOPinWrite(GPIO_PORTB_BASE,INLB ,0x00 );
        	GPIOPinWrite(GPIO_PORTB_BASE,INHC ,0x00 );
        	break;
        case 6:
        	GPIOPinWrite(GPIO_PORTB_BASE,INLA ,INLA );
        	GPIOPinWrite(GPIO_PORTB_BASE,INHB ,0x00 );
        	GPIOPinWrite(GPIO_PORTB_BASE,INLB ,0x00 );
        	GPIOPinWrite(GPIO_PORTB_BASE,INHC ,INHC );
        	break;
        case 7:
        	GPIOPinWrite(GPIO_PORTB_BASE,INLA ,INLA );
        	GPIOPinWrite(GPIO_PORTB_BASE,INHB ,0x00 );
        	GPIOPinWrite(GPIO_PORTB_BASE,INLB ,0x00 );
        	GPIOPinWrite(GPIO_PORTB_BASE,INHC ,0x00 );
        	break;
        case 8:
        	GPIOPinWrite(GPIO_PORTB_BASE,INLA ,INLA );
        	GPIOPinWrite(GPIO_PORTB_BASE,INHB ,0x00 );
        	GPIOPinWrite(GPIO_PORTB_BASE,INLB ,INLB );
        	GPIOPinWrite(GPIO_PORTB_BASE,INHC ,INHC );
        	break;
        case 9:
        	GPIOPinWrite(GPIO_PORTB_BASE,INLA ,INLA );
        	GPIOPinWrite(GPIO_PORTB_BASE,INHB ,0x00 );
        	GPIOPinWrite(GPIO_PORTB_BASE,INLB ,INLB );
        	GPIOPinWrite(GPIO_PORTB_BASE,INHC ,0x00 );
        	break;
        case 10:
        	GPIOPinWrite(GPIO_PORTB_BASE,INLA ,0x00 );
        	GPIOPinWrite(GPIO_PORTB_BASE,INHB ,0x00 );
        	GPIOPinWrite(GPIO_PORTB_BASE,INLB ,INLB );
        	GPIOPinWrite(GPIO_PORTB_BASE,INHC ,INHC );
        	break;
        case 11:
        	GPIOPinWrite(GPIO_PORTB_BASE,INLA ,0x00 );
        	GPIOPinWrite(GPIO_PORTB_BASE,INHB ,0x00 );
        	GPIOPinWrite(GPIO_PORTB_BASE,INLB ,INLB );
        	GPIOPinWrite(GPIO_PORTB_BASE,INHC ,0x00 );
        	break;
        case 12:
        	GPIOPinWrite(GPIO_PORTB_BASE,INLA ,0x00 );
        	GPIOPinWrite(GPIO_PORTB_BASE,INHB ,INHB );
        	GPIOPinWrite(GPIO_PORTB_BASE,INLB ,INLB );
        	GPIOPinWrite(GPIO_PORTB_BASE,INHC ,INHC );
        	break;
        }


		SysCtlDelay(80);
		GPIOPinWrite(GPIO_PORTF_BASE,INHA,0x00);
		SysCtlDelay(80);


    }
}


Viewing all articles
Browse latest Browse all 21644

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>