Can someone give some explains on when to declare a variable to be static? What is the difference with extern one?
This is a standard 'C' language question - nothing specifically to do with Keil or C51.
You should find the answer in a standard 'C' textbook, or try: http://c-faq.com/
www.eskimo.com/.../top.html