View previous topic :: View next topic |
Author |
Message |
StingzLD
Joined: 18 Jul 2010 Posts: 42 Location: Richmond, VA
|
Bit Banging with no UART |
Posted: Sun Jul 18, 2010 2:28 pm |
|
|
Hey Guys!
I am a novice in need of some assistance. I am new to the C language, and I cannot figure out how to bit bang my microcontroller! I am using a PIC16F684, which means there is no UART . I need help figuring out how to bit bang a 16-bit packet to the MAX7219 LED Driver. (The datasheet PDFs are the hyperlinks for the chips). How the data is to be sent to the MAX7219 is on page 7 (or 8 of the actual PDF). I get how the driver wants the information sent, but I just don't understand how to bit bang the packet into DIN. Oh, I guess telling you the pin mapping might be helpful! Haha
PIC = MAX
RC0 (Pin 10) = DIN (Pin 1)
RC1 (Pin 9) = LOAD (Pin 12)
RC2 (Pin 8) = CLK (Pin 13)
Any help will be greatly appreciated.
Thanks in advance! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jul 18, 2010 2:43 pm |
|
|
Use the forum's search page. There's a link for it at the top of the forum.
I did that and found exactly what you need in the Code Library forum.
A bit-banged SPI driver for the Max7219:
http://www.ccsinfo.com/forum/viewtopic.php?t=38882
Also, you wouldn't use a UART to do SPI. You would use the MSSP
module in the PIC. Or do it in software, as shown in the link above.
If you need more help, search for Max7219. There are over a dozen
posts on it in the forum archives. |
|
|
StingzLD
Joined: 18 Jul 2010 Posts: 42 Location: Richmond, VA
|
|
Posted: Sun Jul 18, 2010 3:06 pm |
|
|
Awesome. Thanks! |
|
|
StingzLD
Joined: 18 Jul 2010 Posts: 42 Location: Richmond, VA
|
|
Posted: Sun Jul 18, 2010 4:45 pm |
|
|
Okay. So I printed out that code, and sat down to try and understand it. But I think I am a little confused about what is going on. In the MAX7219.c, he mentions reverse more than once. What exactly is it reversing? Is it the lower 8 bits (D7-D0, the segments)? If it is, can I just delete the section "unsigned int8 reverse" and the code "dis_data=reverse(dis_data); [in the 'void display' section]" if I don't want them reversed? Like I said, I am a novice; and changing things from what the data sheet says will probably confuse me later down the road when I go to rewrite/debug and can't figure out what is going wrong with my main.c code. |
|
|
arunb
Joined: 08 Sep 2003 Posts: 492 Location: India
|
Reversing |
Posted: Tue Jul 20, 2010 12:24 am |
|
|
See the function called reverse (unsigned int8 reverse(unsigned int8 nd_data))
An explanation above the function explains why this needs to be done.
You can also use the MPLAB simulator and step through the code.
thanks
a |
|
|
|