2011-07-10 12:21 PM
I apologize if I am oversimplifying this question, but I'm on the newer side to MCU's.
Anyways, I was trying to figure out putting together a LED array using GPIOC 8-12 and GPIOA 8-12 to make a 4x6 array. I had figured upon using a kind of row addressing to individually light the LED's in the array, but that involves being able to 'ground out' an input pin and set the other on, and vice versa to allow for (4*6)*2=48 total independent LED's.
Down to specifics though, if you didn't care to read the above:
If i have this
GPIOC->CRH &=0xFFFFFF0;
GPIOC->CRH |= 0x00000001; // Set pin 8 at General purpose Push/Pull
GPIOC->BSRR = 1UL<<8; // Turn on LED
and would like to, instead of grounding 8 into the GND pin on the board, ground it into GPIOC pin 9. Is there any way that is done?
Thanks
2011-07-12 06:38 PM
Figured it out.. i think. So with 2 LED's, one hooked up with the cathode into my GPIOA 8 port and the anode into my 3v pin, i can enable it by setting
GPIOA->BRR = 1UL<<8; (a crude solution)
To enable the other, with anode in the GPIO port:
GPIOA->BSRR = 1UL<<8;
both done once the CRH is configured.
If anyone has a better way of doing this, I'd appreciate hearing of it. I also realized that using an 8 bit shift register (serial to parallel) would give me many more possibilities for LED arrays.
2011-07-12 11:19 PM
I hope you just omitted to mention the current-limit resistor for the sake of simplicitly/clarity...?
Also, in addition to the port pin current limit, remember that there is a limit to the total current through all pins of a port, and also a limit to the total current through all pins of the package. You cannot drive all pins simultaneously to the per-pin maximum...