Quantcast
Channel: Microcontrollers
Viewing all articles
Browse latest Browse all 219962

Forum Post: RE: MSP430FR2676: lighting up neopixel leds using MSP430FR2676

$
0
0
Hi Bruce, Many thanks for getting in touch. I made these changes still does light up. I have tried connecting the signal pin to p1.2 and p4.6. I have attached the code for your reference. Many thanks and Kind regards, Criton #include #include "msp430fr2676.h" #include "rgb.h" typedef struct { u_char red; u_char green; u_char blue; } LED; LED leds[NUM_LEDS] = { { 0, 0, 0 } }; // Initializes everything needed to use this library. This clears the strip. void initStrip() { P1SEL0 |= OUTPUT_PIN; // configure output pin as SPI output P1SEL1 &= ~OUTPUT_PIN; // P1.2 as UCB0SIMO per SLASEO5D Table 9-23 UCB0CTLW0 |= UCCKPH + UCMSB + UCMST + UCSYNC + UCSSEL_2; // 3-pin, MSB, 8-bit SPI master UCB0BR0 = 3; // 16 MHz / 3 = .1875 us per bit UCB0BR1 = 0; UCB0CTLW0 &= ~UCSWRST; // Initialize USCI state machine clearStrip(); } // Sets the color of a certain LED (0 indexed) void setLEDColor(u_int p, u_char r, u_char g, u_char b) { leds[p].red = r; leds[p].green = g; leds[p].blue = b; } // Send colors to the strip and show them. Disables interrupts while processing. void showStrip() { __bic_SR_register(GIE); // disable interrupts // send RGB color for every LED int i, j; for (i = 0; i >= 1; // check next bit } } } // send RES code for at least 50 us (800 cycles at 16 MHz) __delay_cycles(800); __bis_SR_register(GIE); // enable interrupts } // Clear the color of all LEDs (make them black/off) void clearStrip() { fillStrip(0x00, 0x00, 0x00); // black } // Fill the strip with a solid color. This will update the strip. void fillStrip(u_char r, u_char g, u_char b) { int i; for (i = 0; i < NUM_LEDS; i++) { setLEDColor(i, r, g, b); // set all LEDs to specified color } showStrip(); // refresh strip } void gradualFill(u_int n, u_char r, u_char g, u_char b); int main(void) { WDTCTL = WDTPW | WDTHOLD; initStrip(); fillStrip(0xFF, 0xFF, 0xFF); showStrip(); while (1) { gradualFill(NUM_LEDS, 0x00, 0xFF, 0x00); // green gradualFill(NUM_LEDS, 0x00, 0x00, 0xFF); // blue gradualFill(NUM_LEDS, 0xFF, 0x00, 0xFF); // magenta gradualFill(NUM_LEDS, 0xFF, 0xFF, 0x00); // yellow gradualFill(NUM_LEDS, 0x00, 0xFF, 0xFF); // cyan gradualFill(NUM_LEDS, 0xFF, 0x00, 0x00); // red } } void gradualFill(u_int n, u_char r, u_char g, u_char b){ int i; for (i = 0; i < n; i++){ // n is number of LEDs setLEDColor(i, r, g, b); showStrip(); _delay_cycles(1000000); // lazy delay } }

Viewing all articles
Browse latest Browse all 219962

Trending Articles



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