Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Thread Closed: Off-topic

???
03/06/04 13:49
Read: times


 
#66110 - Try this out Arif...
Hi Arif,
make appropriate corrections and try this code out.

1. Start a new project in Keil C.
2. Select the target controller and click ok.
3. Right-Click "Target1" in the left hand tab and go to "Options for Target Target1" and fill in the necessary details like the crystal speed etc.
IN the second tab, select the "Create HEX File" option.
4. Select File->New
This gives you a new text file. Save it as "<name>.C" where name is any name you want.
5. Right-Click "SourceGroup1" and select "Add Files to Group". In that select the C file you just saved (blank one).

ONCE done, you are ready to type out the program.

For a generic program, you start off like this...

HINT: There is a program called HELLO.C in the HELLO Directory of the Examples Directory in your Keil INstallation. That should give you a start. But a customised one is....
#include<REG51.H>
#define Port0 P0

bit TimeOut;
int main()
{
  ......   // Initialize your registers here
  ......   // Just like you do in Assembly
  ......   // For eg: EA = 0x81 or something
  ......   // Remember all SFRs are in Upper Case
  TimeOut = 0;
  while(1) // Create an Infinite Loop
  {
    P0 ^= 0x01;
    while(TimeOut == 0);
    TimeOut = 0;
  }
}

void T0_Isr(void) interrupt 1
{
   // Write your Timer 0 ISR here. 
   // Set the Bit TimeOut and Reload TH0 and TL0

   TimeOut = 1;
   TH0 = 0x..;
   TL0 = 0x..;
}


List of 4 messages in thread
TopicAuthorDate
Try this out Arif...            01/01/70 00:00      
   RE: Try this out Arif...            01/01/70 00:00      
   Begin at the neginning            01/01/70 00:00      
      RE: Begin at the neginning            01/01/70 00:00      

Back to Subject List