Jump to content
43oh

NRF24L / Launchpad Example CCS


Recommended Posts

Couldn't find a simple msp430 CCS example of the NRF24L 2.4ghz so I wrote one. Requires 2 msp430g2553 launchpads and 2 NRF24L modules. Press button on 1 launchpad to toggle LED on other launchpad. Note example code assumes you know C language.

 

*Note:  Driver referenced from Brad S, supreme overlord of all C

 

Preview of main (download for full driver set):

//Author: Nathan Zimmerman

//Date: 3/2/14

// Driver referenced from Brad S, supreme overlord of all C



//Launchpad CCS example of NRF24L Driver. Use P1.3 Button to toggle LED on other launchpad. Hence requires 2 NRF modules & 2 launchpads

//Note example uses a fixed packet length of 5.



//GPIO Pinouts



//P2.0 = IRQ

//P2.1 = CSN

//P2.2 = CE



//P1.5 SCLK

//P1.6 MISO

//P1.7 MOSI



//P1.3 Button Launchpad Rev 1.5

//P1.0 Red LED Launchpad Rev 1.5



#include "msp430g2553.h"

#include "stdint.h"

#include "Drivers/rtc.h"

#include "Drivers/clock.h"

#include "Drivers/usi.h"

#include "Drivers/External/NRF24L.h"

#include "Drivers/External/LAUNCHPAD_IO.h"



const uint8_t txMessage[PAYLOAD_WIDTH]= "Hello";



void main(void)

{

    uint8_t rxbuffer[PAYLOAD_WIDTH] = {0,0,0,0,0};

    volatile uint8_t statusData = 0;

    disableWDT();

    setupCoreClock(CLK_16_MHZ);

    setupRLED();

    RLED_OFF;

    setupButton();

    SERIAL_CLASSES spiHandle = { SPI, SMCLK_16MHZ_SPI_CLK_4MHZ, MODULE_B}; // NRF cannot run at max baud 16mhz

    initUSI(&spiHandle);

    initNRF24L();



    statusData = getNrfStatus();



    if(statusData != 0x0E)

    {

        while(1); // NRF failed to init, check pinout or device

    }



    while(1)

    {

        if(recievedRfData())

        {

            getRfBuffer(rxbuffer);

            if(rxbuffer[0]=='H') // newb check for "Hello" Message

            {

                RLED_TOGGLE;

            }

        }

        if(buttonPressed)

        {

            transmitTxData((uint8_t *)txMessage);

            _delay_cycles(16000000); // newb button debounce

        }

        handleRxData();

        handleTxData();

    }





}

 

NRF_Example_NateZ.zip

 

 

 

Link to post
Share on other sites
  • 3 months later...
  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...