4th Semseter files
This commit is contained in:
BIN
4th-Semester-Spring-2023/Embedded/Lectures/Lecture01/.Jan19_CirArea.c.swp
Executable file
BIN
4th-Semester-Spring-2023/Embedded/Lectures/Lecture01/.Jan19_CirArea.c.swp
Executable file
Binary file not shown.
BIN
4th-Semester-Spring-2023/Embedded/Lectures/Lecture01/CirArea.out
Executable file
BIN
4th-Semester-Spring-2023/Embedded/Lectures/Lecture01/CirArea.out
Executable file
Binary file not shown.
16
4th-Semester-Spring-2023/Embedded/Lectures/Lecture01/Jan19_CirArea.c
Executable file
16
4th-Semester-Spring-2023/Embedded/Lectures/Lecture01/Jan19_CirArea.c
Executable file
@@ -0,0 +1,16 @@
|
||||
#include <stdio.h>
|
||||
#define PI 3.141593
|
||||
|
||||
float circleArea(float radius);
|
||||
|
||||
int main()
|
||||
{
|
||||
float radius = 5;
|
||||
printf("Area of circle with radius %4.3f is %4.3f\n", radius, circleArea(radius));
|
||||
return 0;
|
||||
}
|
||||
|
||||
float circleArea(float radius)
|
||||
{
|
||||
return PI * radius * radius;
|
||||
}
|
||||
12
4th-Semester-Spring-2023/Embedded/Lectures/Lecture01/Jan19_SubF.c
Executable file
12
4th-Semester-Spring-2023/Embedded/Lectures/Lecture01/Jan19_SubF.c
Executable file
@@ -0,0 +1,12 @@
|
||||
#include <stdio.h>
|
||||
|
||||
float average(int a, int b, int c)
|
||||
{
|
||||
return (a + b + c) / 3.0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("%4.3f\n", average(4, 5, 6));
|
||||
return 0;
|
||||
}
|
||||
BIN
4th-Semester-Spring-2023/Embedded/Lectures/Lecture01/Jan19_SubF.out
Executable file
BIN
4th-Semester-Spring-2023/Embedded/Lectures/Lecture01/Jan19_SubF.out
Executable file
Binary file not shown.
28
4th-Semester-Spring-2023/Embedded/Lectures/Lecture05/Makefile
Executable file
28
4th-Semester-Spring-2023/Embedded/Lectures/Lecture05/Makefile
Executable file
@@ -0,0 +1,28 @@
|
||||
ifndef $(MSPGCCDIR)
|
||||
MSPGCCDIR=$(HOME)/ti/msp430-gcc
|
||||
endif
|
||||
#paths
|
||||
INCLUDES_DIRECTORY = $(MSPGCCDIR)/include
|
||||
|
||||
DEVICE = msp430fr2355
|
||||
|
||||
# compiler options
|
||||
CC=$(MSPGCCDIR)/bin/msp430-elf-gcc
|
||||
|
||||
CFLAGS = -I . -I $(INCLUDES_DIRECTORY) -mmcu=$(DEVICE) -g -mhwmult=f5series
|
||||
LFLAGS = -L . -L $(INCLUDES_DIRECTORY)
|
||||
|
||||
# mspdebug driver -- used for installation
|
||||
DRIVER:= tilib
|
||||
|
||||
# Compiling
|
||||
all: main.elf
|
||||
|
||||
%.elf : %.c
|
||||
$(CC) $(CFLAGS) $(LFLAGS) $< -o $@
|
||||
|
||||
install: main.elf
|
||||
mspdebug $(DRIVER) "prog $<" --allow-fw-update
|
||||
|
||||
clean:
|
||||
rm -f *.o *.elf
|
||||
62
4th-Semester-Spring-2023/Embedded/Lectures/Lecture05/notes.md
Executable file
62
4th-Semester-Spring-2023/Embedded/Lectures/Lecture05/notes.md
Executable file
@@ -0,0 +1,62 @@
|
||||
# Intro to Embedded Systems Lecture Notes: January 31st, 2023
|
||||
|
||||
## POLLING
|
||||
|
||||
**Initialize the port**
|
||||
|
||||
Output:
|
||||
```c
|
||||
P6DIR |= BIT6;
|
||||
P6OUT &= ~BIT6;
|
||||
```
|
||||
Input:
|
||||
```c
|
||||
P4DIR &= ~BIT1;
|
||||
```
|
||||
Clear LOCKLPM5 (Lock low-power mode) from PMCTL0 (Power management control):
|
||||
```c
|
||||
PMCTL0 &= ~LOCKLPM5;
|
||||
```
|
||||
|
||||
Program the board
|
||||
|
||||
**Floating condition: not 1 or 0**
|
||||
Fix using pull-up/pull-down resistor
|
||||
|
||||
## PULL-UP / PULL-DOWN RESISTORS
|
||||
|
||||
**Pull-up resesistor**
|
||||
- Active Low
|
||||
- Mostly preferrable for MCUs
|
||||
- Safety -> reduces noise
|
||||
|
||||
**Pull-down resistor**
|
||||
- Active high
|
||||
|
||||
## I/O Configuration
|
||||
|
||||
|
||||
| P<sub>x</sub>DIR | P<sub>x</sub>REN | P<sub>x</sub>OUT | Comment |
|
||||
|-------|-------|-------|----------------|
|
||||
| 0 | 0 | X | Input |
|
||||
| 0 | 1 | 0 | Input with PDR |
|
||||
| 0 | 1 | 1 | Input with PUR |
|
||||
| 1 | X | X | Output |
|
||||
|
||||
## LOW POWER MODE
|
||||
|
||||
| SCG<sub>1 | SCG<sub>0 | OSC OFF | CPU OFF | Mode |
|
||||
|------|------|---------|---------|----------|
|
||||
| 0 | 0 | 0 | 0 | Active |
|
||||
| 0 | 0 | 0 | 1 | LPM0 |
|
||||
| 0 | 1 | 0 | 1 | LPM1 |
|
||||
| 1 | 0 | 0 | 1 | LPM2 |
|
||||
| 1 | 1 | 0 | 1 | LPM3 |
|
||||
| 1 | 1 | 1 | 1 | LPM4 |
|
||||
|
||||
## WHEN INTERRUPT HAPPENS
|
||||
- Processor stops what it's doing
|
||||
- Stores information to later resume
|
||||
- Executes interrupt service routine (ISR)
|
||||
- Restores saved information
|
||||
- Resumes execution
|
||||
62
4th-Semester-Spring-2023/Embedded/Lectures/Lecture06/notes.md
Executable file
62
4th-Semester-Spring-2023/Embedded/Lectures/Lecture06/notes.md
Executable file
@@ -0,0 +1,62 @@
|
||||
# Intro to Embedded Systems Lecture Notes: February 2nd, 2023
|
||||
|
||||
## Registers
|
||||
|
||||
|Reg Name|Function|
|
||||
|-------|-------|
|
||||
|P<sub>x</sub>SEL| Function select register
|
||||
|P<sub>x</sub>DIR | Whether input or output
|
||||
|P<sub>x</sub>OUT| Output value
|
||||
|P<sub>x</sub>IN| Input value
|
||||
|P<sub>x</sub>REN |Pull-up / Pull-down resistor
|
||||
|P<sub>x</sub>IE | Interrupt enable
|
||||
|P<sub>x</sub>IFG | Interrupt flag register
|
||||
|P<sub>x</sub>IES | Interrupt edge select register
|
||||
|
||||
|
||||
## P<sub>x</sub>SEL
|
||||
|
||||
|P<sub>x</sub>SEL1|P<sub>x</sub>SEL0| I/O Function
|
||||
|----|-----|----
|
||||
|0|0|General purpose I/O
|
||||
|0|1|ADC
|
||||
|1|0|Timer
|
||||
|1|1|Digital Communication (SPI / UART / I<sup>2</sup>C)
|
||||
|
||||
## Using P<sub>x</sub>SEL to Modify Behavior of P<sub>1.7</sub>
|
||||
|
||||
### GPIO Function
|
||||
```
|
||||
P1SEL1 &= ~BIT7;
|
||||
P1SEL0 &= ~BIT7;
|
||||
```
|
||||
|
||||
### ADC Function
|
||||
```
|
||||
P1SEL1 &= ~BIT7;
|
||||
P1SEL0 |= BIT7;
|
||||
```
|
||||
|
||||
### Timer Function
|
||||
```
|
||||
P1SEL1 |= BIT7;
|
||||
P1SEL0 &= ~BIT7;
|
||||
```
|
||||
|
||||
### SPI (Requires 4 Pins)
|
||||
```
|
||||
P1SEL1 |= 0xF0;
|
||||
P1SEL0 |= 0xF0;
|
||||
```
|
||||
|
||||
## Using P<sub>x</sub>IE, P<sub>x</sub>IFG, and P<sub>x</sub>IES
|
||||
|
||||
|Level Triggering | Edge Triggering |
|
||||
|--|--|
|
||||
|Signal asserted when high| Signal asseted on positive* edge
|
||||
|Signal not asserted when low|
|
||||
|
||||
\* positive edge only used when using positive edge triggering. Negative edge triggering also exists
|
||||
|
||||
|
||||
|
||||
BIN
4th-Semester-Spring-2023/Embedded/Lectures/Lecture07/L#4-Interrupts_Polling.pptx
Executable file
BIN
4th-Semester-Spring-2023/Embedded/Lectures/Lecture07/L#4-Interrupts_Polling.pptx
Executable file
Binary file not shown.
54
4th-Semester-Spring-2023/Embedded/Lectures/Lecture07/notes.md
Executable file
54
4th-Semester-Spring-2023/Embedded/Lectures/Lecture07/notes.md
Executable file
@@ -0,0 +1,54 @@
|
||||
# Intro to Embedded Systems Lecture Notes: February 7th, 2023
|
||||
|
||||
## Using Interrupts
|
||||
```c
|
||||
#define INTERRUPT_PINS 0x03
|
||||
|
||||
int main(void)
|
||||
{
|
||||
P4IE |= INTERRUPT_PINS; // Local interrupt enable
|
||||
P4IFG |= INTERRUPT_PINS;
|
||||
P4IES |= INTERRUPT_PINS;
|
||||
|
||||
_enable_interrupts(); // Global interrupt enable
|
||||
__bis_SR_register(GIE);
|
||||
|
||||
while (true)
|
||||
{
|
||||
...
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Port 4 interrupt service routine
|
||||
void __attribute__ ((interrupt(PORT4_VECTOR))) Port_4 (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
## Interrupt Servicing Summary
|
||||
1. Interrupt Pending
|
||||
2. Complete Current Instruction
|
||||
3. Clear SR
|
||||
4. Retrieve starting address of ISR & put address in PC
|
||||
5. Execute ISR
|
||||
6. Pop SR and PC from stack
|
||||
7. Continue to main program
|
||||
|
||||
## Multiple Interrupts
|
||||
### Three Types:
|
||||
1. Reset Interrupt
|
||||
2. Maskable Interrupt
|
||||
- ADC, port, timer, e_USCI
|
||||
- User-asserted event
|
||||
3. Non-Maskable Interrupt
|
||||
- Fault, error detection
|
||||
- Oscillator fault
|
||||
- Flash key violation
|
||||
|
||||
## Priority of Interrupts
|
||||
1. Timers
|
||||
2. e_USCI
|
||||
3. ADC
|
||||
4. Port
|
||||
Reference in New Issue
Block a user