Jump to content

H3rv3

Members
  • Content Count

    3
  • Joined

  • Last visited

  1. Hi, I am trying to send some data that I receive from an IR remote using a 2231 launchpad to another one using a 2553 which is used to drive an addressable RGB strip. I cannot use interupts on the 2553 as this would mess up the communication to the strip so my idea is to deal with the IR remote on one chip and send some commands to the other one to affect the way the strip is managed (colour change, ...) through SPI with no interupt. I arranged to have this working between two 2231 but I have an issue when using the USCI in the 2553 as slave (receiving). The code I used for the receiver is below. When I run this on the IAR debugger with a break point on the line "data=UCB0RXBUF", it does work, it detects that the 8 bits are received, data becomes the proper value transfered and if the data is 63 (ON button) the LED toggle. It also works when the repeat code is received. When I stop the debugger and run it on its own, it stops working, the LEDs never toggle. I have read about using a CS line but I really would like to keep it without, I did not need it on the 2231 (using the fact that the reset can be made non automatic) and I am sending IR codes at a rate wich is much lower than the scan rate in the receiver, I should be able to ensure that the code is read before I send another one. Any idea on what is not right? Thanks H3rv3 #include "msp430g2553.h" #include "intrinsics.h" #define PIN_LED1 BIT0 // LED1 on the Launchpad #define PIN_LED2 BIT6 // LED2 on the Launchpad unsigned char data=0; // data reduced to command received void init (void) { __disable_interrupt(); BCSCTL1 = CALBC1_1MHZ; // Set DCO to 1MHz same as master DCOCTL = CALDCO_1MHZ; P1DIR = PIN_LED1+PIN_LED2; // output 2 LEDS P1OUT = 0; // outputs to 0 UCB0CTL1 = UCSWRST; // USCI reset UCB0CTL0 = UCMSB; P1SEL = BIT5 + BIT7; P1SEL2 = BIT5 + BIT7; UCB0CTL1 = 0; // enable USCI } void main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop the Watchdog timer init(); while (1) // Loop forever { if ((IFG2 & 4 == 4) || (UCB0STAT & UCOE >0)){ // interupt flag is up (8 bits received) data=UCB0RXBUF; // unload receive register UCB0CTL1 = 1; // reset USCI UCB0CTL0 = UCMSB; UCB0CTL1 = 0; // prepare for receiving 8 bits } if (data>0){ if (data==63){ P1OUT ^= PIN_LED1;// Toggle LED1 } if (data==1 ){ // If repeat code P1OUT ^= PIN_LED2; // Toggle LED2 } data=0; } } }
  2. H3rv3

    TLS3008 RGB Leds on Launchpad

    That was sku 111682, unfortunately now sold out :-( I don't know if they have a similar strip, I keep looking but cannot find one. These ones were good. H3rv3
  3. I bought some addressable RGB Leds from Dealextreme and instead of the expected WS2801 chip, they came with TLS3008 drivers (8bit control for each colour, single wire, different protocol from WS2811 too). It took some time with the osciloscope to get the timing right but this now works perfect. This is in C rahter than assembly but I can get a decent update rate. I do not work with the full 50 Leds as there is not enough RAM in the chip I use (2231) but I tried looping the code to work with the full length, that worked ok except on one set of Leds which was sometimes lagging, I think that this is due to the extra time used by the loop when returning. If all the RGB data is in a table there should be no issue. I will check this when I have a better chip. I am making a kind of light organ - vu meter mix with a short string of 6 Leds and the update on the audio is faster than I need. This is compiled with IAR. Any comments and improvements welcome! H3rv3 // TLS3008 based 6 RGB LEDs string test application for MSP430 // Based on DonJuanito99 for arduino //THIS IS THE WORKING CODE // includes #include "msp430g2231.h" #include "intrinsics.h" // defines #define PULSEUS1 33 // Manchester half period in clock cycles (2.5us) to 1 #define PULSEUS0 22 // Manchester half period in clock cycles (2.5us) to 0 #define PULSEUS2 9 // used for end of command last 0 delay #define EOSYNCDELAYMS 50750 // Pause duration at end of SYNC frame (3.5ms) #define EORESETMS 29000 // Pause duration at end of RESET frame (2ms) #define EOFDELAYMS 5000 // Pause duration at end of each frame (of 50 LEDs RGB data) (0.35ms) #define UP 0x00 #define DOWN 0x01 #define HOLD 0x02 // variables //all reds //unsigned char RGBTable [18]={0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00}; //one color each //unsigned char RGBTable [18]={0xFF,0x00,0x00,0x0F,0x00,0x0F,0x00,0x00,0xFF,0x00,0x0F,0x0F,0x00,0xff,0x00,0x0f,0x0F,0x00}; //all off unsigned char RGBTable [18]; int i; int bc; char led_red = 1; char led_green = 255; char led_blue = 1; char red = UP; char blue = HOLD; char green = DOWN; // routines void reset(void); // sends reset frame void sync(void); // sends sync frame void frame_start(void); // sends emty data frame (last bit, out of procedure delay) void updateRGB (void); // sends the data to the leds void bitc(char); // bit sending procedure to send commands void bitd(char); // bit sending procedure to send data void main(void) { //pin setup output and 0 P1DIR |= BIT0; P1OUT &= ~BIT0; //Stop watchdog timer WDTCTL = WDTPW + WDTHOLD; //Set clock at 16MHz DCOCTL = DCO0 + DCO1; BCSCTL1 = RSEL0 + RSEL1 + RSEL2 + RSEL3; //Disable interupts __disable_interrupt(); // initialising strings reset(); sync(); reset(); sync(); reset(); sync(); while(1) { // reset(); // not required in this loop, consider regular reset // sync(); // not required in this loop, consider regular re-sync // send the data to the string updateRGB(); // the code below is just for the show while (P1IN & BIT3) {} //fade logic switch (red){ case UP: ++led_red; if (led_red == 255) {red = DOWN; green = HOLD; blue = UP; led_green=0;} break; case DOWN: --led_red; if (led_red == 0) {red = HOLD;} break; case HOLD: break; }//end switch switch (blue){ case UP: ++led_blue; if (led_blue == 255) {blue = DOWN; green = UP; red = HOLD;led_red=0;} break; case DOWN: --led_blue; if (led_blue == 0) {blue = HOLD;} break; case HOLD: break; }//end switch switch (green){ case UP: ++led_green; if (led_green == 255) {green = DOWN; red = UP; blue = HOLD;led_blue=0;} break; case DOWN: --led_green; if (led_green == 0) {green = HOLD;} break; case HOLD: break; }//end switch RGBTable [0]=led_red; RGBTable [1]=led_green; RGBTable [2]=led_blue; RGBTable [3]=led_blue; RGBTable [4]=led_green; RGBTable [5]=led_red; RGBTable [6]=led_red; RGBTable [7]=led_blue; RGBTable [8]=led_green; RGBTable [9]=led_blue; RGBTable [10]=led_red; RGBTable [11]=led_green; RGBTable [12]=led_green; RGBTable [13]=led_blue; RGBTable [14]=led_red; RGBTable [15]=led_green; RGBTable [16]=led_red; RGBTable [17]=led_blue; } //end while } // end main() void updateRGB(void) // send the RGBTable data to the string { frame_start(); // prepare to send data __delay_cycles (PULSEUS0-4); for(i=0;i<18;i++) // Repeat for 6 leds * 3 data blocks { // Start tag (= 0 bit) P1OUT &= ~BIT0; // set to 0 __delay_cycles(PULSEUS1); P1OUT |= BIT0; //set to 1 __delay_cycles(4); for (bc=0x80;bc!=0;bc>>=1) bitd( RGBTable[i] & bc ); // send the 8 data bits __delay_cycles (6); } P1OUT &= ~BIT0; __delay_cycles (EOFDELAYMS); //pass value from chip to LED (=send a complete frame start) frame_start(); __delay_cycles (PULSEUS1-3); P1OUT &= ~BIT0; // write a low __delay_cycles (EOFDELAYMS); } void bitd(char { if (b==0){ P1OUT &= ~BIT0; // set to 0 __delay_cycles(PULSEUS1); P1OUT |= BIT0; //set to 1 __delay_cycles (4); } else{ P1OUT |= BIT0; // set to 1 __delay_cycles(PULSEUS1); P1OUT &= ~BIT0; //set to 0 __delay_cycles (4); } } void bitc(char { if (b==0){ P1OUT &= ~BIT0; // set to 0 __delay_cycles(PULSEUS1); P1OUT |= BIT0; //set to 1 __delay_cycles (PULSEUS0); } else{ P1OUT |= BIT0; // set to 1 __delay_cycles(PULSEUS1); P1OUT &= ~BIT0; //set to 0 __delay_cycles (PULSEUS0); } } void sync() { bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(0); bitc(0); bitc(0); bitc(1); bitc(0); bitc(0); bitc(0); bitc(0); bitc(0); bitc(0); bitc(0); bitc(0); bitc(0); bitc(0); bitc(0); __delay_cycles (PULSEUS2); // additional delay on last 0 P1OUT &= ~BIT0; // now set to 0 __delay_cycles (EOSYNCDELAYMS); // end of sync frame delay } void reset() { bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(0); bitc(1); bitc(0); bitc(0); __delay_cycles (PULSEUS2); // additional delay on last 0 P1OUT &= ~BIT0; // now set to 0 __delay_cycles (EORESETMS); // end of reset frame delay } void frame_start() { bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(0); bitc(0); bitc(1); P1OUT &= ~BIT0; __delay_cycles(PULSEUS1+9); P1OUT |= BIT0; //set to 1 // last 0 bit has no delay (delay will be set outside due to procedure return delays) }
×