Jump to content

naren

Members
  • Content Count

    3
  • Joined

  • Last visited

  1. Setting UCB0BR0 to 3 or 4 works. I am trying to run at a lower frequency (8MHz) and setting UCB0BR0 to 2 should work in theory but looks like there are longer delays than the ws2812b is willing to tolerate... Right now with 16Mhz I see the leds work well with a 500KHz bitstream. If that's the (only) sweet spot for the leds, the code needs to be reworked if I want to run at a lower frequency... As an aside, for some reason the code lights up 14 of the 15 leds... the last one in the strip does not light up. The LED is not broken... and even after playing around with the array index I am not able to figure out why...
  2. Thanks roadrunner84 for the DCOCTL explanation. TI documentation hasn't been the easiest to read especially when it spans multiple documents. The for-loop intro was thoughtful and yes, I've had enough experience with code to see your point. Cheers. Naren
  3. Hi, I'm trying to drive 15 ws2812b leds using a g2553 sitting on a Launchpad I'm finding the following behaviour a bit confusing and am wondering if anyone can provide an explanation... The code below is borrowed from RobG's post (http://forum.43oh.com/topic/2680-group-buy-10-o-rgb-smd-led-with-built-in-controller/page-4#entry23841 ) If I try to run at 16MHz the strip does not behave/work as expected BCSCTL1 = CALBC1_16MHZ; DCOCTL = CALDCO_16MHZ; However, if I set DCOCTL to CALDCO_1MHZ and keep BCSCTL1 at CALBC1_16MHZ (see code below) , the strip works fine... Is the clock calibration on my G2553 shot? How would one reset this? #include <msp430g2553.h> typedef unsigned char u_char; typedef unsigned int u_int; typedef struct { u_char r; u_char g; u_char b; } RGBLED; #define DATA_OUT_PIN BIT7 void sendRGB(u_char numberOfLEDs); RGBLED data[15] = { 0, }; // 0.5m strip void main(void) { WDTCTL = WDTPW + WDTHOLD; BCSCTL1 = CALBC1_16MHZ; DCOCTL = CALDCO_1MHZ; // setup USIB P1SEL |= DATA_OUT_PIN; P1SEL2 |= DATA_OUT_PIN; UCB0CTL0 |= UCCKPH + UCMSB + UCMST + UCSYNC; // 3-pin, 8-bit SPI master UCB0CTL1 |= UCSSEL_2; // SMCLK UCB0BR0 |= 0x03; // 1:3 - 16MHz/3 = 0.1875us UCB0BR1 = 0; UCB0CTL1 &= ~UCSWRST; u_char x = 0; u_char dir = 1; while (1) { u_char c = 0; while (c < 14) { data[c].r = x; //x << 3; data[c].b = x; //127 - (x << 3); data[c].g = x; //255 - (x << 3); data[c+1].r = 255 - x; data[c+1].b =255 - x ; data[c+1].g =255 - x; c+=2; } sendRGB(15); __delay_cycles(100000); if (dir) { x++; if (x == 0xFF) dir = 0; } else { x--; if (x == 0) dir = 1; } } } void sendRGB(u_char numberOfLEDs) { u_int c = 0; u_char led = 0; u_char leds[3]; u_char d; while (c < numberOfLEDs) { leds[0] = data[c].g; leds[1] = data[c].r; leds[2] = data[c].b; while (led < 3) { u_char b = 0; d = leds[led]; while (b < 8) { while (!(IFG2 & UCB0TXIFG)) ; (d & 0x80) ? (UCB0TXBUF = 0xF0) : (UCB0TXBUF = 0xC0); d <<= 1; b++; } led++; } led = 0; c++; } __delay_cycles(800); // delay 50us to latch data, may not be necessary } Thanks for any pointers Naren
×
×
  • Create New...