4 Function & Interrupts Flashcards

1
Q

What are functions in C?

A
  • A function is a re-usable block of code that contains variables and expressions
  • Examples might include the __delay_ms() function we have seen already
  • The concept is the same as using call and return in assembly (but in assembly we called the function a sub-routine)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Example function block in C?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

The position of function blocks?

A

Main is a special function, it defines the entry point of our program

Any other functions (libraries or our own) need to be defined before main, so that they exist before we try and use them

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Example function overall structure within the code?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Advantages of functions?

A
  • Re-use a block of code many times
  • Decompose complex programming tasks into simpler steps
  • Reduce code duplication
  • Divide large tasks between team members
  • Individual functions can be tested in isolation before assembly into a larger program
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are interrupts?

A
  • Interrupts are a hardware feature of the PIC, so they work in basically the same way in C as assembler
  • Just like if and while, interrupts can be a useful tool to change the flow of your code (for example in response to a button press)
  • Once configured, an external interrupt will call the ISR
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Example ISR code checking PORTB?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Standards are designed to create code that is:

A

Organised Easy to read Easy to understand Maintainable Efficient All major companies will adopt their own set of rules

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Why are coding standards important?

A
  • Up to 80% of lifetime cost of software is maintenance
  • Rarely is the original author responsible for the entire life-cycle
  • Commercial software must be reliable and efficient
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Example indentation in the code?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Comments details?

A

start with //

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is revision control?

A

Having software in place to monitor how many version of code there are.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly