Question: #include inc/hw_ints.h #include inc/hw_memmap.h #include inc/hw_types.h #include driverlib/sysctl.h #include driverlib/interrupt.h #include driverlib/gpio.h #include driverlib/timer.h #include driverlib/uart.h #include utils/uartstdio.h int main(void) { unsigned long ulPeriod; //Clock
#include "inc/hw_ints.h" #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "driverlib/sysctl.h" #include "driverlib/interrupt.h" #include "driverlib/gpio.h" #include "driverlib/timer.h" #include "driverlib/uart.h" #include "utils/uartstdio.h"
int main(void) { unsigned long ulPeriod;
//Clock set to 40MHz SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
//System Peripheral Enables SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
//GPIO Pin Config GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3); GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
//UART Config UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); //FIFO UARTFIFOLevelSet(UART0_BASE, UART_FIFO_TX4_8, UART_FIFO_RX4_8); //set FIFO level to 8 characters UARTFIFOEnable(UART0_BASE); //enable FIFOs //Interrupt IntEnable(INT_UART0); //enable the UART interrupt UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT); //only enable RX and TX interrupts //Initialize UARTStdioInit(0); //tells uartstdio functions to use UART0 UARTprintf("\033[2J\033[H IF YOU WANT TO ENCRYPT, TYPE E; IF YOU WANT TO DECRYPT, TYPE D: "); // erase screen, put cursor at home position (0,0),
//Timer Config TimerConfigure(TIMER0_BASE, TIMER_CFG_32_BIT_PER); ulPeriod = (SysCtlClockGet() / 10) / 2; TimerLoadSet(TIMER0_BASE, TIMER_A, ulPeriod -1); //Interrupt IntEnable(INT_TIMER0A); TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); //Enable TimerEnable(TIMER0_BASE, TIMER_A);
//Interrupt Enable IntMasterEnable();
while(1) { //SysCtlDelay(10000000); //1second } }
// Interrupts Handlers
void Timer0IntHandler(void) { // Clear the timer interrupt TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT); // Read the current state of the GPIO pin and // write back the opposite state if(GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_2)) { GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0); } else { GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 4); } }
void UARTIntHandler(void) {
unsigned long ulStatus; unsigned char received_character; ulStatus = UARTIntStatus(UART0_BASE, true); //get interrupt status UARTIntClear(UART0_BASE, ulStatus); //clear the asserted interrupts while(UARTCharsAvail(UART0_BASE)) //loop while there are characters in the receive FIFO { received_character = UARTCharGet(UART0_BASE);
UARTCharPutNonBlocking(UART0_BASE, received_character); //echo character
if (received_character == 13) UARTCharPutNonBlocking(UART0_BASE, 10); //if CR received, issue LF as well GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2); //blink LED SysCtlDelay(SysCtlClockGet() / (1000 * 3)); //delay ~1 msec GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0); //turn off LED } }
----------------------------------------------------------------------------------------------------------
(Tm4c123gxl uart)Build on the code above to implement the following



2. Assignment Implement, in C or assembly language, an encryption/decryption program that meets the following requirements: Input Your program should prompt the user for three separate inputs from the keyboard, as follows: 1. The prompt: IF YOU WANT TO ENCRYPT, TYPE E; IF YOU WANT TO DECRYPT, TYPE D . The user will tvpe E or D. A real world program should also detect any other character typed and respond with THAT IS AN ILLEGAL CHARACTER PLEASE TRY AGAIN. We will assume in this assignment that the user can type an E or D correctly. 2. The prompt: ENTER THE ENCRYPTION KEY (A SINGLE DIGIT FROM 1 TO 9) The user will type a single digit, from 1 to 9. Again, we will assume the user is not an Aggie, . Your program will accept this digit, store it in a location of choice in RAM, and use it to 3. The prompt: INPUT A MESSAGE OF NO MORE THAN 20 CHARACTERS. WHEN . The user will input a character string from the keyboard, terminating the message with the . Your program will store the message, starting a location of choice in RAM.. Since the message and can successfully hit digit keys on the keyboard encrypt or decrypt the message. DONE. PRESS
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
