Commit d27d4a73 authored by homsm's avatar homsm Committed by overleaf
Browse files

Update on Overleaf.

parent 6a626b25
......@@ -115,6 +115,8 @@ Receivers detect the baud-rate based on the length of the start bit and adjust t
\textbf{implementation}: Slide 3-37
\subsubsection{SPI (3-40)}
=Serial Peripheral Interface Bus\\
Used in short distance communication. Contains 4 lines:
\begin{itemize}
\item \textbf{SCLK} Clock signal, used to synchronize communcation with slaves.
......@@ -123,28 +125,30 @@ Used in short distance communication. Contains 4 lines:
\item \textbf{SS} Slave select, Active Low: Used to address a slave /to show that communication is valid
\end{itemize}
Master and Slave simply consist of two shift register, with every clock cycle from the SCLK the data gets shifted from Master to slave and vice versa.\\
Slaves can be independent or daisy-chained (3-42)
\includegraphics[width=\linewidth]{images/spi.JPG}
\subsection{Interrupts}
Different devices can send interrupt request to the processor. In order to ignore or react to them, a controller (NVIC - Nested Vector Interrupt Controller) is used. The NVIC can mask or dis-/enable interrupts.
\\
It also decides which interrupt has priority and what interrupt service routine should be executed. In order to do that, it contains a vector table with an entry for each interrupt type and pointer to the code that should be executed \\
It also decides which interrupt has priority and what \textbf{interrupt service routine} should be executed. In order to do that, it contains a vector table with an entry for each interrupt type and pointer to the code that should be executed \\
\textbf{Interrupt Execution}:
\begin{enumerate}
\item Interrupt Occurs (UART, GPIO, sth)
\item A flag gets set in the IFC (interrupt flag control register to mark the interrupt.
\item CPU/NVIC reacts to interrupt. CPU stops executing, stores current Execution pointer.
\item A flag gets set in the IFC (interrupt flag control register to mark the interrupt.There is one for each interrupt source.)
\item CPU/NVIC reacts to interrupt. CPU stops executing, stores current Execution pointer, mask interrupts globally, determines source of interrupt.
\item Interrupt Service routine gets called
\item Saves state of system, Executes custom code of subroutine.
\item Saves state of system, Executes custom code of subroutine(interrupt's code).
\item restores state, unmasks interrupt.
\end{enumerate}
$\rightarrow$ See Code implementation in the Lab section\\
\textbf{Interrupt VS Polling}
\begin{itemize}
\item Utilization \textbf{u}: average percentage the processor is busy
\item Computation \textbf{c}: processing time for the event
\item Overhead \textbf{h}: Time overhead due to interrupt
\item Overhead \textbf{h}: Time overhead to handle interrupt
\item Period \textbf{P}: Polling period
\item Interval time \textbf{T}: Minimal time between two events
\item Deadline \textbf{D}: Maximal time between event arrival and finishing
......
\section{Exercises and Laboratory (ES-Lab)}
\subsection{Lab 1}
\textbf{Pull-up resistor:}\\
makes sure the pin is on low voltage if the button is pressed.
\textbf{Pull-down resistor:}\\
makes sure the pin is on high voltage if the button is pressed.
\includegraphics[width=0.4\linewidth]{images/resistor.JPG}
\subsection{Interrupts}
By default all interrupts are disabled. The following steps are necessary to
configure a GPIO interrupt on the MSP432.
......@@ -16,6 +26,9 @@ Interrupt\_enableInterrupt()
\item Enabling interrupts globally (set global interrupt enable (GIE) bit). Interrupt\_enableMaster() \\
\end{enumerate}
After these steps any new event on the pin will generate an interrupt, preempt the microprocessor and start the execution of the corresponding ISR
\includegraphics[width=\linewidth]{images/flags.JPG}
\subsection{Code Interrupt}
\begin{python}
volatile bool buttonFlag = false;
......@@ -74,7 +87,62 @@ Interrupt_enableMaster ();
GPIO_setOutputLowOnPin(GPIO_PORT_P2 , GPIO_PIN1);
GPIO_setOutputLowOnPin(GPIO_PORT_P2 , GPIO_PIN2);
\end{python}
\begin{python}
/* Code that is executed when processor is not busy with handling an interrupt */
while (1)
{
// Sleep while waiting for an interrupt
PCM_gotoLPM3();
// After interrupt occurred
if (button1Flag)
{
/* Increase and send counter for button S1 via UART */
count1 += 1;
uart_println("S1: %d", count1);
button1Flag = false;
}
if (button2Flag)
{
/* Increase and send counter for button S2 via UART */
count2 += 1;
uart_println("S2: %d", count2);
button2Flag = false;
}
}
\end{python}
\subsection{Interrupt Service Routine}
\begin{python}
/*
* PORT 1 interrupt service routine
*/
//m1_2s//
void PORT1_IRQHandler(void)
{
uint32_t status;
/* Get the content of the interrupt status register of port 1 */
status = GPIO_getEnabledInterruptStatus(GPIO_PORT_P1);
if (status & GPIO_PIN1)
{
/* Toggle green LED of LED2 */
GPIO_toggleOutputOnPin(GPIO_PORT_P2, GPIO_PIN1);
/* Set the a flag to inform the while loop that the button has been pressed */
button1Flag = true;
GPIO_clearInterruptFlag(GPIO_PORT_P1, status);
}
else if (status & GPIO_PIN4)
{
/* Toggle blue LED of LED2 */
GPIO_toggleOutputOnPin(GPIO_PORT_P2, GPIO_PIN2);
/* Set the a flag to inform the while loop that the button has been pressed */
button2Flag = true;
GPIO_clearInterruptFlag(GPIO_PORT_P1, status);
}
}
\end{python}
\subsection{Generating Periodic Interrupts}
\begin{python}
/* Timer_A0 up mode configuration parameters */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment