Let me describe my project: I'm bulding a count-up/count-down large format display timer with big 5x7 led dot matrices. I'm trying to use Keil uVision3 to program my microcontroller. I'm trying to use an at89s52 to control an TLC5920 LED driver chip. The LED driver chip needs Sin, SCK, LATCH(bar), BLANK, and CSEL0-2 from the microcontroller. I am a decent C programmer. But, I do not know how to use Keil to do things like send P2.0 serial data or P2.1 a high or low signal or monitor P2.7 for a pulse from a keypad. Could someone please direct me to a knowledge base that explains how to program such things in Keil evaluation? Also, I would greatly appreciate any project advice. Thanks, Lee Lerner
You need to start by reading the uVision Getting Started Guide, and working through the example projects in it. (The uVision Getting Started Guide is available on the 'Books' tab in the 'Project' Window; The 'Books' window is also available via the 'Help' menu; failing all that, search for GS51.PDF in your Keil folder) And don't forget those documents commonly referred to as the "bible" for the 8051: Chapter 1 - 80C51 Family Architecture: http://www.semiconductors.philips.com/acrobat/various/80C51_FAM_ARCH_1.pdf Chapter 2 - 80C51 Family Programmer's Guide and Instruction Set: http://www.semiconductors.philips.com/acrobat/various/80C51_FAM_PROG_GUIDE_1.pdf Chapter 3 - 80C51 Family Hardware Description: http://www.semiconductors.philips.com/acrobat/various/80C51_FAM_HARDWARE_1.pdf
The tutorial helped a lot. I now know how to code general I/O and such. I'm a bit confused about how to send my LED driver chip serial data. I have an 8MHz oscillator for the microcontroller. How do I set up the proper baud rate and send serial data to the LED driver? Thanks, Lee
You need to look at the datasheet for the LED driver chip. It will show you the required timing relationships between the clock, data, latch, and whatever other signals. It's just a matter of getting your code to follow those rules! You could also look on the manufacturer's website for application notes, example code, etc, to help you
I have reviewed the datasheets but I am still very confused about how to send serial data to my led driver chip in Keil code. Example: SCON = 0x50; TMOD |= 0x20; TH1 = 0xf3; TR1 = 1; TI = 1; PCON |= 0x80; I believe that this enables serial mode 1 at a baud rate of 9600 (I have an 8MHz oscillator). But now how do I send 16 bits to the Sin of the LED driver chip. The driver chip has a Sin and Sclk (I'm not sure where to connect the Sclk to on the microcontroller). Do I just write a char to SBUF? Thanks, Lee
the probglem is that you use the UART, instead use one regular port pin as clock and one as data. You do not need to rewire, if uou leave the UART alond P3.0 and P3.1 are regular port pins. It looks suspiciously like SPI search on that. Erik
"SCON = 0x50; TMOD |= 0x20; TH1 = 0xf3; TR1 = 1; TI = 1; PCON |= 0x80;" As Erik says, this is all UART stuff. That's for asynchronous comms. Your interface is synchronous (it has a clock signal), so the UART is of no use there at all! You just need two port pins, and set them high and low as shown in the timing diagrams in the datasheet
I understand the timing diagrams and such and have worked through many examples. Yet, I still do not know how to even set a pin high or low. Do I do it using some hex value?
Read P0^1 = 1; P3^7 = 0; or you can just write to the port. P2 = 0x23;
P0^1 = 1; P3^7 = 0;
See the section titled Parallel Port I/O in the uVision Getting Started Guide