Hi, I'm just switching over from Atmel AVR's to work on a project that involves working with AT89C51SND1 micro. Perviously, I've used Atmel's CodeVision Compiler and now switching over to Keil. I have very few basic questions that I need help with, regarding the comipler. As I understand that to declare a port as an input in Kiel, the format is: P1 = 0xff; // (Entire Port 1 is Input) what i'd like to know is if i want to read a pin value on P1, how do i do it? is it... some_variable = P1; because in CodeVision it is as following: some_variable = PINA; and similarly how to write to a port, is it: P1 = value; in Codevision it is: PORTA = value; I've downladed some exmaple programs of the keil website and they've been helpful, but just want to confirm if i'm on the right track. Thank you
Yes Manny you are going in the right direction. Suggest that you go a little further into the 'Geting Started' manual and work a few of the Port I/O examples. Keil has included several new data types to allow symbolic addressing of the SFRs. Check out the SFR and SBIT examples. Bradford
Hi The 51 ports are quisi-bidirectional. To read X=P1 to write P1=X Normally you would write onse to the port to make them highs ( that is the P1 =0xFF) Note that if the port is driving a load it may not read back what you wrote. The load may affect the pin voltage. This is since the read is from the Port not the latch.
Stop! Before you go any further read "the bible". Without the knowledge gained there you will fall and stumble again and again. Erik here are the links to "the bible" Chapter 1 http://www.semiconductors.philips.com/acrobat/various/80C51_FAM_ARCH_1.pdf chapter 2 http://www.semiconductors.philips.com/acrobat/various/80C51_FAM_PROG_GUIDE_1.pdf chapter 3 http://www.semiconductors.philips.com/acrobat/various/80C51_FAM_HARDWARE_1.pdf