davebranton 11 Posted June 16, 2013 Share Posted June 16, 2013 Hi, I'm building a simple LED matrix display, using 4094's to drive the columns of the matrices, and I would like to use the universal serial module to clock the data into the shift registers. So I set up a simple test, and had the serial module clock out 7 bits (I have three 7x5 matrix panels, and at first I'm just using one), but I didn't see the results I expected. When I got a scope on the outputs, I saw the serial module clocking out 11 bits! I had to set the bit counter register USICNT to 4 to convince the serial module to output 7 bits. The code looks something like //set strobe high P1OUT |= BIT3; // load the data (this was a single bit moving through the byte) USISRL = <data>; // clock out 7 bits (!!) USICNT = 4; // wait until they're out while(USICNT); // set strobe low, this will latch the outputs on the shift register P1OUT &= ~BIT3; I know that USICNT reaches zero at the point I expect, because I can see the strobe go low when the final bit is clocked out. But what is going on here? Does anyone know why seven bits get clocked out when I set USICNT to four? Quote Link to post Share on other sites
davebranton 11 Posted June 18, 2013 Author Share Posted June 18, 2013 Well it looks like the culprit was Grace - which I think loaded the USICNT register with 8, causing the SPI clock to start. So by the time I got to my code the clock had already been running for a bit, and so writing 8 to the register caused me to see about 12 bits on the output. Once I threw away the grace project and started again doing everything by hand it all worked fine. I'm going to start another thread about this project because it involves a couple of custom boards and I don't want to have my stupid question at the top of the thread Quote Link to post Share on other sites
spirilis 1,265 Posted June 18, 2013 Share Posted June 18, 2013 I think you meant USI in the title not USCI... Haven't read your code in detail yet but be aware there's an errata bug in USI modules--the very first xfer you do will send 1 more bit than you intended. I get around that in my code implementations by doing a strawman xfer after initialization with none of the Chip Select lines for the attached peripherals active. Sent from my Galaxy Note II with Tapatalk Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.