Embedded Systems Help Site

Welcome to the ECE2564 help site!
Use the dropdowns below and see if this answers your question.
If not, feel free to come in to OH!
Feedback is always appreciated, let us know how to improve the site =)

HW1
Converting numbers to character arrays

There are a few functions available to you to convert numbers into strings. Here are a few! Read up on the documentation and try some things out. The best thing you can do to help yourself learn is to play around with new concepts.
printf sprintf snprintf

Add leading 0s

You can do additional formatting things inside of the string formatting functions. Mess around with things, look some stuff up. Particularly revolving around %d or %b or %x. Maybe put some numbers in there, who knows?

Decimal to 8-bit unsigned binary

The first listed step is to make sure the number is able to be fit into an 8-bit unsigned number. Calculate by hand if you need, and remember that it should be unsigned. The specifier for binary is b.

Decimal to hex

The first listed step is to make sure the number is able to be fit into a 2-digit hex number. It may help to convert 2-digit hex into binary first to conceptualize what numbers can fit. This one is signed still. The specifier for hexadecimal is x.

Decimal to twos complement

You need to check if the input is within the range of an 8-bit signed binary number. You've already done something similar. Feel free to use something you've already written, either copy and paste or call a function. Did you know that bitwise operators work on integers? I think that that's really cool! Hopefully you do too ;)

Twos complement to decimal

This question has a different validity check. The inputted number should have 8 characters in only 1s and 0s. To convert it to decimal, you need an extra step or two. Remember that the inputted number is a decimal int that looks like a binary. Do some math to convert the form of this binary (each decimal place is a power of 2 rather than a power of 10) or find some functions that may be of help. There is one such function in the code currently.

HW2
P1 - What are the warnings that are there upon opening?

What are the warnings that are there upon opening?
179-D is a warning that lets you know you made a variable that is not used anywhere in the code. Do not worry about it this time, but they should not be in the codes you write.

P1 - 0x?

These numbers are in hexadecimal (0-F)

P1 - Unsigned?

Normally, ints have the range of -2,147,483,648 to 2,147,483,647. The keyword "unsigned" means that the variable does not use the negative range. Unsigned ints have a range of 0 to 4,294,967,296<

P1 - Signed?

Most data types are assumed to be signed, but we are just specifying here.

P1 - Not expecting the number?

That is the point of this problem. The key lies within the "signed" and "unsigned". The most significant bit determines whether or not the variable is negative in signed variables. Keep that in mind, as well as how large of a number each data type can handle.
It may also help to change the way the numbers are displayed in the debugger.

P2 - What are the warnings that are there upon opening?

552-D is very similar to 179-D. Don't worry about it here, but it should not be in codes that you write.
188-D is a very helpful hint to the task at hand. Enjoy the problem.

P2 - What is #define?

A definition of some word. Here, every instance of "ARRAY_SIZE" in the code will be treated as if it were the number 9.

P2 - Why is the loop running infinitely?

This is the question that needs to be solved. For a hint, look at warning 188-D.

P3 - What are the warnings that are there upon opening?

179-D is a warning that lets you know you made a variable that is not used anywhere in the code. Do not worry about it this time, but they should not be in the codes you write.

P3 - What are all of these extra header files I've never seen before?

The header files grlib and LcdDriver are used to interact with the board. They will become more important and make more sense as the class continues.

P3 - What are all of these extra functions and structs I've never seen before?

Graphics_Context is a struct that contains a lot of important information about the LCD screen.
initializeGraphics uses the graphics context described earlier. Do not mess with it.
make_time_string and smallNumToString are custom functions that we will be exploring in this assignment.

P3 - Why are some symbols in ' '?

A symbol enclosed in ' ' represent an ascii character. It is essentially one character of a string (""). <

P3 - What about the 0 and NULL?

The 0 corresponds to the ascii character to end the string/message/whatnot. NULL is defined as 0 in a header file.

P3 - What is string0[0]?

C uses "0 based indexing", which just means that the first item in an array is called 0.

P3 - How to use Graphics_drawString?

Ctrl click on the function, this will take you to the definition in the header file. Here, you will see what parameters to put when you call the function. Some header files are very detailed, while some are not.
Take a look at the header file, as well as the times it was used in this example.

P3 - How does snprintf differ from strncpy?

snprintf will have the extra space as null
characters (ends the string) while strncopy will not. These will be evident when you run the code. There are ways to have strncopy add a null character, https://cplusplus.com/ is an incredibly helpful website.

P3 - strncat?

Take a look at the header file or https://cplusplus.com/
Or even better - play around with it and find out what happens.

P3 - make_time_string?

There is documentation above the function definition for you to read. It details the inputs and the intended output.
You need to find some way to create the intended output using the methods provided to you.

P3 - Hint for make_time_string

I heavily recommend looking at:
snprintf
and
printf

HW3
P1 - What is this new header file?

driverlib is a library intended to help interface with the board.

P1- What is BIT0?

BIT0 is a mask with a single 1 in the LSB. There are many other masks, all viewable in the header file that is opened when you ctrl click on BIT0.

P1 - How to set specific bits?

This was a concept learned in class, please attend ;)
A particular bit can be target by a bit mask, and the different bit operations will change the behavior of how it is set.
x&0=0 x&1=x
x|0=x x|1=x
x^0=x x^1=!x
Remember to view the debugger to see if your implementations work.

P2 - How to complete this problem?

In previous problems, most-all of the information needed was written in comments next to the problem. Here, everything is in the PDF.

P2 - #define pt2?

COLOR_MASK is defined as an expression this time. It treated in the code as (BIT2 | BIT3) exactly.
Defines work by essentially replacing the first word/identifier/etc with everything that follows.

P2 - typedef enum?

enumerations are collections of (for our purposes) words all contained together.
It is a good coding practice that helps keep variables organized and understandable.
They will be used a lot in this course.
The problem mentions that something is missing, look through the code to find out what.

P2 - struct?

A struct is like a class, except there are no functions inherently inside of it. There are only data members.
The problem mentions that something is missing, look through the code to find out what.

P2 - Functions that have "color_t" or "LSR_t" instead of "int" or "void" and the like?

All of these (color_t, LSR_t, int, void, etc) are all datatypes. The function is returning the datatype it is declared with. It is the exact same process as int or void, just with a different datatype.

P2 - getColorSetting/getIntensitySetting/getFlickeringSetting?

getColorSetting has been completed for you. Take a look at the structure of it, and try to understand the logic before completing the other functions.

P2 - updateIntensity/updateColor/updateFlicker?

None of these have been completed for you. Also notice that all of these have a void return type. We are using pointers to change the value of the LSR_t itself. Use the ideas from the previous set of functions to get a handle on how to do these.

P2 - makeLSR?

Use the 3 inputs and format them with bit operations and masks to create and return an LSR_t. The usage of these functions also give a little more insight on enums.

P2 - increaseLight?

We are using the pointer to directly modify the LSR_t again. There are many methods to completing this task. Try things out and find what works!

P2 - Dot Notation?

Use a dot to access members or functions belonging to the object.
Here, .lightSetting is accessing the member called lightSetting inside of the light_t struct.

P2 - I'm still stuck. Hint please?

Sure - try things and play around with it. Read through the code and try to understanding what's happening for all of the functions. A good understanding of how variables and functions are called and used is a great thing to have to stay comfortable in this class.

HW4
P1 - Why do all of the P1 variables have a 0x40004C.. value?

These variables are pointers, and they point to some place in memory. Because they are pointers, we use an asterisk (*) to dereference them, which just means we are using the value in the memory address stored in the pointer. The memory address is the value of the pointer, but the memory address itself can have a value attached to it. The IN, OUT, REN, and DIR pointers all have memory address which can be found in the registers or memory viewer, but here we have variables set to the address for easy access.

P1 - What is the 2<<1 and the like?

The << operator in this context is a bitshift. In this question, it is shifting the value 2 by 1 bit to the left, making it 4. These are very useful for making bitmasks and such.

P1 - MSP User guides?

There are multiple references and manuals that you can look at. They are available on the external site and contain many useful pieces of information on how to use the board. Reading documentation is a very important part of this course, you should learn how to do it early on.

P1 - Why don't the value update as soon as I press the button?

In debug mode, the processor is stuck in time. It is not receiving any inputs, doing any operations, or many other things. By stepping over, you are running the code line by line, and only then will the board update with its peripherals.

P1 - What is the importance of the number updating?

Take a look at the manuals mentioned. The bits correspond to a certain pin of the processor. Read up on why they are important, and check out the class notes.

P1 - How do I go about changing BLR with the button?

A framework has been laid out with you already with LL1 and LB1. Analyze what is going on and try to recreate it with the task at hand. Remember to use the informative tools you have to your advantage. Find the register BLR and BB2 exist in, and set the pointers. From there, set the values in the memory addresses referenced by the pointers.

P2 - Configuring the pins?

Pins can be configured much easier than in question 1. In this problem, we see usage of some functions from a header file. Use these from now on, and make/use HALs with them. See the initialize function, and maybe check out the header file.

P2 - Set up HAL functions?

The functions TurnOn_Launchpad_LL1 and LB1isPressed are examples of functions that could be in a HAL. There are no real rules for what needs to be in a HAL, but there is a convention for what should be. Follow the example provided to make your own functions and use the documentation available.

P2 - What is the best way to check that my functions and configurations are correct?

Do and change one thing at a time. Check all of the buttons with a working LED, and then check all of the LEDs with a working button. You will only need to set all of these up once, so if you have found the numbers already, use them.

P2 - How do I make the Turn_BoosterPack_LED function?

This function takes in an input, and turns LEDs on and off as a result. The input is a color_t, which is an enum with limited values. You can use this to your advantage by making a simple control structure tailored to the enum. If you do not know how to make the colors requested, feel free to research about how colors act in light. The given enum is not complete, but notice how OFF is used in the switch statement.

P2 - How do I impliment the Turn_BoosterPack_LED function?

This can be implemented the same way a lot of the functions we have seen so far can. If a button in pressed, do a thing. If a different button is pressed, do something else. Place it all in the while loop to make it run constantly like we have been doing.

Errors
10247-D creating output section "__" without a SECTIONS specification

You may need to change the compiler or linker.
Project -> Properties -> General -> Linker command file -> msp432p401r.cmd
Project -> Properties -> General -> Compiler version -> there are limited options, find one that works with the linker

179-D variable "_" was declared but never referenced

The variable listed was created somewhere, but it has no usage in the code. Remove/comment/use it to get rid of this warning.

112-D statement is unreachable

The line of code this is attached to will never be run. This may be due to an infinite loop or some control structure that will make this line never occur. Review your logic and placement.

225-D function "_" declared implicitly

The function referenced was never declared in the header file. You must place this function in the header file to make it work as intended.

12-D parsing restarts here after previous syntax error

There is a large error somewhere in the code, sometimes not near the line listed. Look for missing ; } " and other syntax characters.

169-D argument of type "__" is incompatible with parameter of type "__"

The line listed includes an object that is not compatible with the function. Check with the header file to ensure the correct type of variable is used, and adjust accordingly.

176-D expression has no effect

The line referenced does not do anything that is important later in the code sequence. Remove it or make it do something productive.

177-D subscript out of range

I got this error by trying to reference array position -1, which doesn't exist. Don't do that.

141 too many arguments in function call

The function has too many arguments. Check the header file to see how the declaration differs and adjust accordingly.

167 too few arguments in function call

The function has too little arguments. Check the header file to see how the declaration differs and adjust accordingly.

148 declaration is incompatible with ...

There is a discrepancy between the function declaration in the header file and the function definition in the c file

gmake Error 1

These are very useful. They show the set of files where the issues are.

gmake: Target 'all' not remade because of errors

Read as is, there are errors and the project can't compile

20 identifier "_" is undefined

The variable referenced was never declared. Maybe check the spelling or declare the variable.

66 expected a ;

The code seems the think you're missing a ;. This is not always the case, and the error may not be in the listed line. Double check the line and lines above for missing ; } " and other syntax characters.

18 expected a )

Something is missing, might not be a right parenthesis. Take a look around and find the odd one out.

156 expression must have a struct or union type

There is an object in the listed line that has an incorrect usage of . or ->
These have two different meanings, usually the compiler will steer you right with which to use.

1965 cannot open source file

The header file referenced is not able to be opened. Check to make sure the name is correct and the file exists.

138 expression must be a modifiable lvalue

Check the logic of the expression, make sure it EXACTLY represents what you want it to do.

76 operand of "*" must be a pointer

The added * is attached to something that is not supposed to be a pointer, remove it.

121 return value type does not match the function type

The returning object for the function does not match the declared type of the function. Change one or the other.

Debugging Tips
What is debugging?

Debugging is a method of finding what the issues in the code are. There are a few different ways to debug; all of them have their values and none of them are incorrect. Find a method that works the best for you.

Debugging method: debugger

Using the debugger is the primary method taught in the course for how to debug. To do this method, make sure the board is attached and hit the bug icon in the top left. You may need to wait a minute for it to start. \nOnce in debug mode, you can place breakpoints around the code. If you were to hit play, the code would run continuously until it reached the breakpoint. Put some breakpoints around where you think the problem is. If you don't ever reach it, place some breakpoints higher up and find out why. Use the variables tab in conjuction with your knowledge of how your code flows to fix the issue.

Debugging method: peripherals

Using the peripherals is another good way to debug. If you attach a known working light to some operation, whenever that operation occurs, the light should turn on. This is useful if you don't know what the flow of the code is once it has been flashed. Attach as many lights as you need, just remember to keep track of what they are.

Debugging method: AAAAAAAA

The name is a joke to what the actual practice is. This is a last resort that is simple to set up. Use print statements (UART, graphics) at key places in the code to track where it is and what is happening. If you don't have the other means available, this works fine. For this course, you should use the debugger with breakpoints.

CCS Debugger tips

There are a couple of useful features in the CCS debugger. \nBreakpoints: use breakpoints to control where you want to retake manual control over the code. Hit the play button and the code will run and run and run until it reaches the breakpoint, where you can do manual steps.\nThe manual steps are step in, step over, and step return. \nStep in: use this to move into something. It could be a function, loop, or third thing.\nStep over: this will be the most commonly pressed button. It just runs the line of code. If it's a fucntion, it will run the whole function. Step return: If inside a function, it will complete the function.

CCS More debugger buttons

The pause button will stop the code wherever it is. If it keeps getting stuck somewhere, use this to find out where it is. \nThe restart button will start debugging over. It saves a lot of time compared to stopping and starting.

Debugging is not working for me.

Try another method. There are many different ways of doing it, find one that works for you. Debugging is a very important skill to learn. If you would like help, feel free to come into office hours!

In debugging, my loop does one iteration and skips the rest???

The debugger may have lied to you. Try stepping into the loop instead of stepping over.