Jump to content
Fmilburn

DriverLib Examples for the MSP430F5529

Recommended Posts

Energia and Arduino users eventually get to the point where they need more direct access to the hardware if they take on more complicated projects.  In addition to the direct access of registers using the provided header files, TI offers DriverLib which contains abstractions for accessing the peripherals.

 

To better understand the peripherals, and to check out DriverLib, I recently created 20+ short examples for my own edification.  All of them were written for the MSP430F5529 LaunchPad and most of the peripherals are covered.  In some cases pushbuttons, LEDs, resistors, potentiometer, etc. are required that you probably have on hand.  A multimeter is required, and in some cases an oscilloscope and logic analyzer are instructive but not necessary.

 

post-45284-0-92397700-1478474666_thumb.jpg

DriverLib SPI Example 13A_USCI_B_SPI_MCP41010_digiPot

 

All of the examples are located here:  https://github.com/fmilburn3/MSP430F5529_driverlib_examples

 

It is necessary to have some understanding of the registers before using DriverLib because the DriverLib documentation doesn't describe how the peripherals and their registers work.  The documentation for registers is located in the User

Share this post


Link to post
Share on other sites

Thank you @@Fmilburn

 

Your article got me interested, again, in driverlib.   In fact, I was not able to get it working when I first tried some months ago, and I'm having the same problem as I did on my first attempt.

 

Here's an open question to you or the forum  -----> 

 

When I try driverlib, I can't get CCS to find it in my computer's file system; likely a path problem; despite trying, I've been unable to solve it  ---   any ideas, folks?

 

Here's Frank's simple 'blink' which I tried today and the CCS error output......   (I underlined the offending line.

 

 

 


**** Build of configuration Debug for project test-5229-drvlib-1 ****
"C:\\ti\\ccsv6\\utils\\bin\\gmake" -k all
'Building file: ../main.c'
'Invoking: MSP430 Compiler'
"C:/ti/ccsv6/tools/compiler/msp430_15.12.3.LTS/bin/cl430" -vmspx --data_model=restricted --use_hw_mpy=F5 --include_path="C:/ti/ccsv6/ccs_base/msp430/include" --include_path="C:/ti/ccsv6/tools/compiler/msp430_15.12.3.LTS/include" --advice:power=all -g --define=__MSP430F5529__ --diag_warning=225 --diag_wrap=off --display_error_number --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU23 --silicon_errata=CPU40 --printf_support=minimal --preproc_with_compile --preproc_dependency="main.d"  "../main.c"
>> Compilation failure
subdir_rules.mk:7: recipe for target 'main.obj' failed
"../main.c", line 2: fatal error #1965: cannot open source file "driverlib.h"
1 catastrophic error detected in the compilation of "../main.c".
Compilation terminated.
gmake: *** [main.obj] Error 1
gmake: Target 'all' not remade because of errors.
**** Build Finished ****

 

 

and the code...

#include <msp430.h> 
#include "driverlib.h"
#define  DELAY_CYCLES  1045000

/*
 * main.c
 */
int main(void) {


   WDT_A_hold(WDT_A_BASE);
   GPIO_setAsOutputPin(RED_LED);
   for(; {
      GPIO_setOutputHighOnPin(GPIO_PORT_P1,GPIO_PIN0);
      _delay_cycles(DELAY_CYCLES);
      GPIO_setOutputLowOnPin(GPIO_PORT_P1,GPIO_PIN0);
      _delay_cycles(DELAY_CYCLES);
   }
}  WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer
	
	return 0;
}

Share this post


Link to post
Share on other sites

Hi @@veryalive,
I find it easiest to do as @@bluehash suggests and specify a blank DriverLib project in CCS at the bottom of the window when creating a project and before pasting in code. It can also be imported after creation as described in the MSP430 Design Workshop.

 

EDIT:  Back at my computer again...  The selection I am referring to is highlighted at bottom left in the attached photo

post-45284-0-96705500-1478552283_thumb.jpg

 

 

Share this post


Link to post
Share on other sites

You could always use 

void GPIO_toggleOutputOnPin ( uint8_t  selectedPort,     uint16_t  selectedPins 

 

Simplifies the loop code a bit...

)
 

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


×