Module 345
Module 345
Embedded Systems
Dr. Rohini. P
Department of ECE,
IIITDM Kancheepuram
Main Oscillator (MOSC) : It can use an external clock source or an external crystal.
Low-Frequency Internal Oscillator (LFIOSC) : An on-chip internal 30 kHz Oscillator used for
1. Set BYPASS2 (bit 11) - At this point the PLL is bypassed - no system clock divider
2. Specify the crystal frequency in the four XTAL bits using the code - OSCSRC2 bits are cleared to select the main
oscillator as the oscillator clock source
4. Configure and enable the clock divider using the 7-bit SYSDIV2 field. If the 7-bit SYSDIV2 is n, then the clock
will be divided by n+1 (To get 80 MHz from 400 MHz PLL - divide by 5 - place a 4 into the SYSDIV2 field)
5. Wait for the PLL to stabilize by waiting for PLLRIS (bit 6) in the SYSCTL_RIS_R to become high.
Timer/Counter operation
24-bit counter decrements at bus clock
With 80 MHz bus clock, decrements every 12.5 ns
Counting is from n → 0
Assume RELOAD= n n=0xFFFFFF
Initialization (4 steps)
Step1: Clear ENABLE to stop counter
Step2: Specify the RELOAD value
Step3: Clear the counter via NVIC_ST_CURRENT_R
Step4: Set NVIC_ST_CTRL_R
CLK_SRC = 1 (bus clock is the only option)
INTEN = 0 for no interrupts
ENABLE = 0 to enable
void SysTick_Init(void){
NVIC_ST_CTRL_R = 0; // 1) disable SysTick during setup
NVIC_ST_RELOAD_R = 0x00FFFFFF; // 2) maximum reload value
NVIC_ST_CURRENT_R = 0; // 3) any write to CURRENT clears it
NVIC_ST_CTRL_R = 0x00000005; // 4) enable SysTick with core clock
}
// The delay parameter is in units of the 80 MHz core clock(12.5 ns)
void SysTick_Wait(uint32_t delay){
NVIC_ST_RELOAD_R = delay-1; // number of counts
NVIC_ST_CURRENT_R = 0; // any value written to CURRENT clears
while((NVIC_ST_CTRL_R&0x00010000)==0){ // wait for flag
}
}
// Call this routine to wait for delay1*10ms
void SysTick_Wait10ms(uint32_t delay1){
unsigned long i;
for(i=0; i<delay; i++){
SysTick_Wait(800000); // wait 10ms
}t
Dr. Rohini. P, Department of ECE, IIITDM Kancheepuram. (Email: [email protected])
Finite State Machine (FSM)
State \ Input 00 01 10 11
goN (100001,30) goN waitN goN waitN
waitN (100010,5) goE goE goE goE
goE (001100,30) goE goE waitE waitE
waitE (010100,5) goN goN goN goN
When current flows through both coils, the motor does not spin
Latency - time between when the I/O device indicated service is required and the time when service is initiated
Includes hardware delays in the digital hardware plus computer software delays.
For an input device, software latency - time between new input data ready and the software reading the data
For an output device, latency - delay from output device idle and the software giving the device new data to output.
A real-time system is one that can guarantee a worst case latency - the software response time is small and bounded - to satisfy
overall specification of the system, such as no lost data.
Throughput or bandwidth is the maximum data flow in bytes/second that can be processed by the system
Priority determines the order of service when two or more requests are made simultaneously
Priority also determines if a high-priority request should be allowed to suspend a low priority request that is currently being
processed
To output data using the UART, the software will first check to make sure the transmit FIFO is not full (it will wait if TXFF is 1) and then
write to the transmit data register (UART0_DR_R )
Shifted out in order - start, b0, b1, b2, b3, b4, b5, b6, b7, and then stop
Even though the transmit data register is at the same address as the receive data register, the transmit and receive data registers are two
separate registers.
Turn on the clock for the digital port in the RCGCGPIO register.
The alternative function for these pins must also be selected. In particular we set bits in both the AFSEL and PCTL registers.
The OE, BE, PE, and FE are error flags associated with the receiver.
You can see these flags in two places: associated with each data byte in UART0_DR_R or as a separate error register in UART0_RSR_R.
The overrun error (OE) is set if data has been lost because the input driver latency is too long.
PE is a parity error
The framing error (FE) will get set if the baud rates do not match.
The software can clear these four error flags by writing any value to UART0_RSR_R.
The UART0_CTL_R control register contains the bits that turn on the UART.
We set TXE, RXE, and UARTEN equal to 1 in order to activate the UART device.
GPIO_PORTC_PCTL_R = (GPIO_PORTC_PCTL_R&0xFF00FFFF)+0x00220000;
Two devices communicating with synchronous serial interfaces (SSI) operate from the same clock
(synchronized)
With a SSI protocol, the clock signal is included in the interface cable between devices
The master device creates the clock, and the slave device(s) uses the clock to latch the data (in or out.)
The slave select SSI0Fss - control signal from master to slave signal signifying the channel is active
The second line, SCK, is a 50% duty cycle clock generated by the master
The SSI0Tx (master out slave in, MOSI) is a data line driven by the master and received by the slave
The SSI0Rx (master in slave out, MISO) is a data line driven by the slave and received by the master
In order to work properly, the transmitting device uses one edge of the clock to change its output, and
the receiving device uses the other edge to accept the data
NVIC enable
Level of Priority
Pushes 8 register on stack – R0, R1, R2, R3, R12, LR, PC, PSR --- R0 on top