-
Notifications
You must be signed in to change notification settings - Fork 4
Assignment 3.1
THIS WILL BE IN YOUR FINAL EXAM (100% Guarantee or your money back... www.willbeinyourfinalexam.com/willbe_there_i_can_guaranteeIT0110111 .com/is going to be there 1-800-255-willbeintyourfinalexam.com)
- What value does num2 contain if the following statements are executed?
unsigned char num1, num2;
num1=0xA5;
num2=num1 & 0xF0;
Using & as an AND operator we get..
A5 = 1010 0101 (Hex to Binary)
F0 = 1111 0000 (Hex to Binary)
--------------
1010 000 = A0
- What value does num2 contain if the following statements are executed?
unsigned char num1, num2;
num1=0x66;
num2=num1 | 0xF0;
Using | as an OR operator we get..
66 = 0110 0110 (Hex to Binary)
F0 = 1111 0000 (Hex to Binary)
--------------
1111 0110 = F6
- What value does num1 contain if the following statements are executed?
unsigned char num1=0x79;
num1&=0x0F;
Using &= as an AND operator we get..
79 = 0111 1001 (Hex to Binary)
0F = 0000 1111 (Hex to Binary)
--------------
0000 1001 = 09
- What is a “WATCH” Window and why would you use it?
> Watch Window lets you know what is going on step-by-step (rather, memory execution by memory execution) or line by line of what your code/firmware is doing. [Fact: Since your code is held in non-volatile memory devices such as ROM, EPROM, or flash memory it is officially called a FIRMWARE. Software is what you get when you have a Kernel to Hardware translation happening.]
5 and 6) Write a simple C program using a while loop that will count up from 0 to 10. Single step
through the program and look at your count variable in the WATCH window, as it counts. There's a bad-ass way to do this if you want to impress your friends at: (https://github.com/glennlopez/Cpp.Playground/blob/master/c%2B%2B%20tricks/whileLoop_decrementArgument.cpp)
It should be noted that "!=" should NOT be used at every iteration loop scenario. Use your jugement. >= or <= are sometimes better.
unsigned char glenn = 0;
while (glenn !=10)
{
glenn ++;
}
> unsigned char glenn = 10;
> while (glenn !=0)
> {
> glenn --;
> }
Bitwise operators can be tricky, if this doesnt help heres a video explaining what why are... http://youtu.be/HB0TFkQATBo
If you are having trouble with this course, I highly suggest you learn how to program in C using code::blocks before doing anything with your microcontroller. This course is poorly designed and failing at it may not be entirely your fault. How well you do in your courses is a reflection of how good your instructors are -- never give them an excuse to say otherwise. “The mind is not a vessel to be filled, but a fire to be kindled.” — Plutarch