Executing Programs on Microcontrollers & Hexadecimal

In summary, a program written in a higher level computer language like C directs the flow of current through transistors to control the flow of information on a microprocessor. The hexadecimal notation is used to represent the values of binary and decimal.
  • #1
indie452
124
0
Hi
i'm doing a circuits lab in physics at the moment based on programming a PIC16F819 microcontroller. What i don't understand is how the program is executed.
I kind of understand that when a pin is logic high voltage then the bit of the number is one and when it is logic low it is zero.

Also i understand that transistors are used to control the flow of current and this current flow results in a change of circuit voltage which represents the bits of information.
But what else is there to know? How does a progam that we write control the current flow and what does the hexadecimal notation have to do with the chip?

any help is welcome thanks
 
Engineering news on Phys.org
  • #2


indie452 said:
Hi
i'm doing a circuits lab in physics at the moment based on programming a PIC16F819 microcontroller. What i don't understand is how the program is executed.
I kind of understand that when a pin is logic high voltage then the bit of the number is one and when it is logic low it is zero.

Also i understand that transistors are used to control the flow of current and this current flow results in a change of circuit voltage which represents the bits of information.
But what else is there to know? How does a progam that we write control the current flow and what does the hexadecimal notation have to do with the chip?

any help is welcome thanks

There is a good set of articles at HowStuffWorks.com about microprocessors (uPs) and how they work:

http://www.howstuffworks.com/search.php?terms=microprocessor

Transistors are used to make the fundamental building blocks of logic -- logic gates and flip-flops. Flip-flops (FFs) are used as memory to store a single bit. You use sets of FFs to make registers -- a register would be 8 bits wide for the simpler uPs, and can be 16 bits or 32 bits wide or more for more complex uPs.

You use logic gates to route the bits between registers, and the behavior of the logic depends on what is currently in memory, and what your program instructions direct the logic to do. So your program might do something like "Load Register A with 0x10", and then "Increment Register A", and then "Store Register A into memory location 0x1234". Loads, adds, increments, stores, and so on, are typical fundamental uP instructions.


EDIT -- those are fundamental Assembly Langauge instructions. Higher level computer languages like C give you more abstract program control and flow. Higher level languages are compiled into Assembly Langauge as part of the process of getting the program ready to load and run on your uP or uC (microcontroller).
 
  • #3


berkeman said:
"Load Register A with 0x10", and then "Increment Register A", and then "Store Register A into memory location 0x1234".

ok but what does the 0x10 mean is this the hexadecimal notation? if so what is the value? how do you work it out?
 
  • #4


indie452 said:
ok but what does the 0x10 mean is this the hexadecimal notation? if so what is the value? how do you work it out?

Yes, that is standard notation for hexidecimal. 0x for hex, 0b for binary.

In base 10, the numbers represent 1's, 10's, 100's, etc, right?

In base 2 (binary) the numbers represent 1's, 2's, 4's, 8's, etc. So 0b10 = 2 in decimal.

In base 16 (hex), the numbers represent 1's, 16's, 256's, etc. So 0x10 = 16 in decimal.

http://en.wikipedia.org/wiki/Hexadecimal

.
 
  • #5


so does 0x40 = 64
0x41 = 65
0x60 = 96
 
  • #6


indie452 said:
so does 0x40 = 64
0x41 = 65
0x60 = 96

You're on the right track. One hint -- the Windows Programs>Accessories>Calculator has a hex/decimal conversion capability (when in Scientific mode). Try it out, and you can check your equations above.
 
  • #7


thanks forthe tip about the windows calculator didnt know that

thanks for the help
 

1. What is a microcontroller and how does it work?

A microcontroller is a small computer on a single integrated circuit. It contains a processor core, memory, and input/output peripherals, and is designed to perform a specific task. It works by executing instructions and processing data using the processor core, and communicating with external devices through the input/output peripherals.

2. What is the difference between executing programs on a microcontroller and a regular computer?

The main difference is the size and complexity of the programs that can be executed. Microcontrollers have limited memory and processing power, so they are typically used for simple and specific tasks, whereas regular computers can handle more complex and varied programs. Additionally, microcontrollers often have specialized input/output peripherals for interacting with external devices.

3. Why is hexadecimal used in microcontroller programming?

Hexadecimal is a base-16 numbering system that is commonly used in microcontroller programming because it allows for a more compact representation of data compared to binary or decimal. This is important for microcontrollers with limited memory, as it allows for more efficient use of memory space.

4. How do I write and upload a program to a microcontroller?

To write a program for a microcontroller, you will need a programming language like C or assembly, and a specialized integrated development environment (IDE). The program is then compiled and converted into a hex file, which can be uploaded to the microcontroller using a programmer device or through a serial connection.

5. What are some common challenges when executing programs on microcontrollers?

Some common challenges include managing memory constraints, optimizing code for limited processing power, and troubleshooting hardware and peripheral issues. It is also important to consider the power source and any potential interference or noise that could affect the microcontroller's performance.

Similar threads

  • Electrical Engineering
Replies
3
Views
2K
Replies
68
Views
3K
  • Electrical Engineering
Replies
5
Views
1K
  • Electrical Engineering
2
Replies
36
Views
2K
  • Electrical Engineering
Replies
5
Views
2K
  • Electrical Engineering
Replies
26
Views
2K
  • Electrical Engineering
Replies
11
Views
7K
  • Electrical Engineering
Replies
26
Views
4K
  • Electrical Engineering
Replies
11
Views
4K
  • Electrical Engineering
Replies
18
Views
3K
Back
Top