i have an ADUC832 and i attached a keypad.i want to read the keypad with the interrupt method. How can i read P1(into this port i attached the keypad) from Keil? Thanks in advanced.
Assuming that you're working in C, you'll need to #include the appropriate register header file for your target device (reg51.h is nice and generic). Then, you can read from and write to P1 using the name of the port as a global variable in C, like so:
#include <reg51.h> void main(void) { P1=0x55; // set to alternating bit pattern 01010101 }
Okay..i worked with C a lot,and i understand how to write the port(i supose there must exist an initialisation) but how can i read to the port.. I just use, var=P1 and that's it?!? Or there is a special function(i.e. scanf) Thanks for your help, bye.
Read the Getting Started User's Guide (GS51.PDF), Using On-Chip Peripherals, Parallel Port I/O.
You need to read the ADUC832 Data Sheet to see if it has any specific requirements for configuring the Ports. For generic 8051 info you need to read the following 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 "80C51 family hardware description" describes port operation on pages 2-5