I come from more of a web-based programming experience, I'm pretty new to C and to microcontrollers so I'm still learning a lot both about the C language and about the MSP430, and there's probably a very simple solution to my problem... In any way:
I'm using an MSP430G2553 and I'm programming it with Code Composer Studio 5.
I made an application that can animate 3 sets of 40 leds using 5 chained shift registers whose outputs go through 5 darlington arrays (ULN2803, they also have 8 inputs/outputs).
In my program I can animate all 40 leds just fine using 5 "shiftOut()" 's (one for each shift register). Now I thought I would try a more complex / extensive animation, so I put together 4 arrays that hold about 257 values each (each array holds the values for one of the shift registers, I didn't need a fifth array because one of the shift registers will always have "0xFF" for this animation).
I'm trying to iterate through these 4 arrays doing a "shifOut()" for each array (plus another "shiftOut(0xFF)"). But when my program gets to this point it doesn't do the animation, the MSP430 just resets itself and starts all over again.
I couldn't quite figure this one out, I thought it might be some sort of memory overflow problem or something, so I tried breaking everything down into smaller pieces. So instead of having a single for loop that iterates 257 times, I now have 12 for loops that iterate 20 times and 1 last for loop that iterates 17 times, so I still I have a total of 257 iterations, but they are broken down into 13 different for loops. I also broke down my arrays to accomplish this, instead of having 4 arrays with 257 values each, I now have 48 arrays with 20 values each, and 4 arrays with 17 values each (that is, 13 arrays for each shift register, just like I have 13 for loops...)
And when it's broken down, it works. So I'm figuring that must be it, some sort of limit for the types I'm casting in, or some sort of memory limits on the MSP430... But doing it this way I don't have the same control over the "delay()" on each iteration. I wanted to do a nifty calculation on the delay() in order to make a nifty animation, but now that I have 13 different for loops it makes it that much more complicated to calculate the delay() in any nifty fashion.
So my question is, do I really have to break everything down into smaller pieces? or is there a more correct way of casting the arrays (like float instead of int or something like that)?
Here's my code if it helps:
#include <msp430g2553.h>
#include <math.h>
//Define our pins
#define DATA BIT0 // DS -> 1.0
#define CLOCK BIT4 // SH_CP -> 1.4
#define LATCH BIT5 // ST_CP -> 1.5
#define ENABLE BIT6 // OE -> 1.6
#define NUM_REGISTERS 5 // change this to the number of daisy-chained shift registers
#define NUM_OUTPUTS NUM_REGISTERS*8
// Declare functions
void delay ( unsigned int );
void pulseClock ( void );
void shiftOut ( unsigned char );
void enable ( void );
void disable ( void );
void pinWrite ( unsigned int, unsigned char );
void latchOn ( void );
void latchOff ( void );
void allOn( void );
void allOff( void );
void complexanimate( void );
int main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
P1DIR |= (DATA + CLOCK + LATCH + ENABLE); // Setup pins as outputs
enable(); // Enable output (pull OE low)
allOn();
delay(500);
allOff();
delay(500);
complexanimate();
}
// Delays by the specified Milliseconds
// thanks to:
// http://www.threadabort.com/archive/2010/09/05/msp430-delay-function-like-the-arduino.aspx
void delay(unsigned int ms)
{
while (ms--)
{
__delay_cycles(1000); // set for 16Mhz change it to 1000 for 1 Mhz
}
}
// set latch off to enable Shifting bits in
void latchOff( void )
{
//Set latch to low (should be already)
P1OUT &= ~LATCH;
}
// set latch on to set bits to output
void latchOn( void )
{
// Pulse the latch pin to write the values into the storage register
P1OUT |= LATCH;
P1OUT &= ~LATCH;
}
// Writes a value to the specified bitmask/pin. Use built in defines
// when calling this, as the shiftOut() function does.
// All nonzero values are treated as "high" and zero is "low"
void pinWrite( unsigned int bit, unsigned char val )
{
if (val){
P1OUT |= bit;
} else {
P1OUT &= ~bit;
}
}
// Pulse the clock pin
void pulseClock( void )
{
P1OUT |= CLOCK;
P1OUT ^= CLOCK;
}
// Take the given 8-bit value and shift it out, LSB to MSB
void shiftOut(unsigned char val)
{
unsigned char i;
// Iterate over each bit, set data pin, and pulse the clock to send it
// to the shift register
for (i = 0; i < 8; i++) {
pinWrite(DATA, (val & (1 << i)));
pulseClock();
}
}
// These functions are just a shortcut to turn on and off the array of
// LED's when you have the enable pin tied to the MCU. Entirely optional.
void enable( void )
{
P1OUT &= ~ENABLE;
}
void disable( void )
{
P1OUT |= ENABLE;
}
// Some custom effects by me. Can be easily modified, customized, developed.
void allOn( void ){
unsigned int s;
latchOff();
for(s=NUM_REGISTERS;s>0;s--){
shiftOut(0xFF);
}
latchOn();
} void allOff(void){
unsigned int s;
lat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0,0xF8,0xFC,0xFE,0xFF,0xFF,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x0,0x0,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF,0xFF,0xFF,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x0,0x0,0x0,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x0,0x0,0x0,0x0,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x0,0x0,0x0,0x0,0x0,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF};
for (m=0;m<257;m++){
latchOff();
shiftOut(sr5[m]);
shiftOut(sr4[m]);
shiftOut(0xFF);
shiftOut(sr2[m]);
shiftOut(sr1[m]);
latchOn();
delay(50);
}
}
Here is the same code broken down into smaller pieces:
complexanimate1(void){
unsigned int m;
const unsigned int sr1a[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x05,0x0B,0x16,0x2C,0x59,0xB3,0x67,0xCE,0x9C};
const unsigned int sr1b[] = {0x38,0x71,0xE3,0xC7,0x8F,0x1E,0x3C,0x78,0xF0,0xE1,0xC3,0x87,0x0F,0x1F,0x3E,0x7C,0xF8,0xF0,0xE0,0xC1};
const unsigned int sr1c[] = {0x83,0x07,0x0F,0x1F,0x3F,0x7E,0xFC,0xF8,0xF0,0xE0,0xC0,0x81,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFE,0xFC};
const unsigned int sr2a[] = {0x00,0x01,0x02,0x05,0x0B,0x16,0x2C,0x59,0xB3,0x67,0xCE,0x9C,0x38,0x71,0xE3,0xC7,0x8F,0x1E,0x3C,0x78};
const unsigned int sr2b[] = {0xF0,0xE1,0xC3,0x87,0x0F,0x1F,0x3E,0x7C,0xF8,0xF0,0xE0,0xC1,0x83,0x07,0x0F,0x1F,0x3F,0x7E,0xFC,0xF8};
const unsigned int sr2c[] = {0xF0,0xE0,0xC0,0x81,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x01,0x03,0x07};
const unsigned int sr4a[] = {0x00,0x80,0x40,0xA0,0xD0,0x68,0x34,0x9A,0xCD,0xE6,0x73,0x39,0x1C,0x8E,0xC7,0xE3,0xF1,0x78,0x3C,0x1E};
const unsigned int sr4b[] = {0x0F,0x87,0xC3,0xE1,0xF0,0xF8,0x7C,0x3E,0x1F,0x0F,0x07,0x83,0xC1,0xE0,0xF0,0xF8,0xFC,0x7E,0x3F,0x1F};
const unsigned int sr4c[] = {0x0F,0x07,0x03,0x81,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x80,0xC0,0xE0};
const unsigned int sr5a[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0xA0,0xD0,0x68,0x34,0x9A,0xCD,0xE6,0x73,0x39};
const unsigned int sr5b[] = {0x1C,0x8E,0xC7,0xE3,0xF1,0x78,0x3C,0x1E,0x0F,0x87,0xC3,0xE1,0xF0,0xF8,0x7C,0x3E,0x1F,0x0F,0x07,0x83};
const unsigned int sr5c[] = {0xC1,0xE0,0xF0,0xF8,0xFC,0x7E,0x3F,0x1F,0x0F,0x07,0x03,0x81,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0x7F,0x3F};
for (m=0;m<20;m++){
latchOff();
shiftOut(sr5a[m]);
shiftOut(sr4a[m]);
shiftOut(0xFF);
shiftOut(sr2a[m]);
shiftOut(sr1a[m]);
latchOn();
delay(250);
}
for (m=0;m<20;m++){
latchOff();
shiftOut(sr5b[m]);
shiftOut(sr4b[m]);
shiftOut(0xFF);
shiftOut(sr2b[m]);
shiftOut(sr1b[m]);
latchOn();
delay(200);
}
for (m=0;m<20;m++){
latchOff();
shiftOut(sr5c[m]);
shiftOut(sr4c[m]);
shiftOut(0xFF);
shiftOut(sr2c[m]);
shiftOut(sr1c[m]);
latchOn();
delay(150);
}
}
void complexanimate2(void){
unsigned int m;
const unsigned int sr1d[] = {0xF8,0xF0,0xE0,0xC0,0x80,0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80};
const unsigned int sr1e[] = {0x00,0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF,0xFF,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0x00,0x01};
const unsigned int sr1f[] = {0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF,0xFF,0xFF,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x01};
const unsigned int sr2d[] = {0x0F,0x1F,0x3F,0x7F,0xFF,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F};
const unsigned int sr2e[] = {0xFF,0xFF,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0x00,0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF,0xFF};
const unsigned int sr2f[] = {0xFF,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF,0xFF};
const unsigned int sr4d[] = {0xF0,0xF8,0xFC,0xFE,0xFF,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE};
const unsigned int sr4e[] = {0xFF,0xFF,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF,0xFF};
const unsigned int sr4f[] = {0xFF,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF,0xFF};
const unsigned int sr5d[] = {0x1F,0x0F,0x07,0x03,0x01,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01};
const unsigned int sr5e[] = {0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF,0xFF,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x80};
const unsigned int sr5f[] = {0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF,0xFF,0xFF,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x00,0x80};
for (m=0;m<20;m++){
latchOff();
shiftOut(sr5d[m]);
shiftOut(sr4d[m]);
shiftOut(0xFF);
shiftOut(sr2d[m]);
shiftOut(sr1d[m]);
latchOn();
delay(100);
}
for (m=0;m<20;m++){
latchOff();
shiftOut(sr5e[m]);
shiftOut(sr4e[m]);
shiftOut(0xFF);
shiftOut(sr2e[m]);
shiftOut(sr1e[m]);
latchOn();
delay(75);
}
for (m=0;m<20;m++){
latchOff();
shiftOut(sr5f[m]);
shiftOut(sr4f[m]);
shiftOut(0xFF);
shiftOut(sr2f[m]);
shiftOut(sr1f[m]);
latchOn();
delay(50);
}
}
void complexanimate3(void){
unsigned int m;
const unsigned int sr1g[] = {0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0x00,0x00};
const unsigned int sr1h[] = {0x00,0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80};
const unsigned int sr1i[] = {0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFC};
const unsigned int sr2g[] = {0xFF,0xFF,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F};
const unsigned int sr2h[] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07};
const unsigned int sr2i[] = {0x0F,0x1F,0x3F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0x00,0x00};
const unsigned int sr4g[] = {0xFF,0xFF,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE};
const unsigned int sr4h[] = {0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0};
const unsigned int sr4i[] = {0xF0,0xF8,0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x00};
const unsigned int sr5g[] = {0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x00};
const unsigned int sr5h[] = {0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01};
const unsigned int sr5i[] = {0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x3F};
for (m=0;m<20;m++){
latchOff();
shiftOut(sr5g[m]);
shiftOut(sr4g[m]);
shiftOut(0xFF);
shiftOut(sr2g[m]);
shiftOut(sr1g[m]);
latchOn();
delay(75);
}
for (m=0;m<20;m++){
latchOff();
shiftOut(sr5h[m]);
shiftOut(sr4h[m]);
shiftOut(0xFF);
shiftOut(sr2h[m]);
shiftOut(sr1h[m]);
latchOn();
delay(100);
}
for (m=0;m<20;m++){
latchOff();
shiftOut(sr5i[m]);
shiftOut(sr4i[m]);
shiftOut(0xFF);
shiftOut(sr2i[m]);
shiftOut(sr1i[m]);
latchOn();
delay(150);
}
}
void complexanimate4(void){
unsigned int m;
const unsigned int sr5j[] = {0xF8,0xF0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF,0xFF};
const unsigned int sr5k[] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01};
const unsigned int sr5l[] = {0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0};
const unsigned int sr5m[] = {0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF};
const unsigned int sr4j[] = {0x00,0x00,0x00,0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFC,0xF8};
const unsigned int sr4k[] = {0xF0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF,0xFF};
const unsigned int sr4l[] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
const unsigned int sr4m[] = {0x00,0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
const unsigned int sr2j[] = {0x00,0x00,0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x3F,0x1F};
const unsigned int sr2k[] = {0x0F,0x03,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF,0xFF};
const unsigned int sr2l[] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
const unsigned int sr2m[] = {0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
const unsigned int sr1j[] = {0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF,0xFF};
const unsigned int sr1k[] = {0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80};
const unsigned int sr1l[] = {0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x3F,0x1F,0x0F,0x07,0x03};
const unsigned int sr1m[] = {0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF};
for (m=0;m<20;m++){
latchOff();
shiftOut(sr5j[m]);
shiftOut(sr4j[m]);
shiftOut(0xFF);
shiftOut(sr2j[m]);
shiftOut(sr1j[m]);
latchOn();
delay(100);
}
for (m=0;m<20;m++){
latchOff();
shiftOut(sr5k[m]);
shiftOut(sr4k[m]);
shiftOut(0xFF);
shiftOut(sr2k[m]);
shiftOut(sr1k[m]);
latchOn();
delay(75);
}
for (m=0;m<20;m++){
latchOff();
shiftOut(sr5l[m]);
shiftOut(sr4l[m]);
shiftOut(0xFF);
shiftOut(sr2l[m]);
shiftOut(sr1l[m]);
latchOn();
delay(50);
}
for (m=0;m<17;m++){
latchOff();
shiftOut(sr5m[m]);
shiftOut(sr4m[m]);
shiftOut(0xFF);
shiftOut(sr2m[m]);
shiftOut(sr1m[m]);
latchOn();
delay(20);
}
}
// END