Professional Documents
Culture Documents
Microprocessors
Eee-342
Lab Report-##
Code:
#include "debug_prints.c"
#define BAUD0 9600 // Baud Rate for UART
#define MYUBRR (F_CPU/8/BAUD0-1)
int main()
{
unsigned char key_pressed = 0;
//Initalizting UART, Print UBRR value and F_CPU
UART0_init(MYUBRR);
printSerialStr("Muhammad Umar");
while (1)
{
key_pressed = read_keypad();
if(key_pressed != 0) //wait for key to be pressed
{
_delay_us(100);
KEYPAD_PORT_ROWS|=0x0F;// Pull-up the rows
KEYPAD_DDR_ROWS&=0x00;// Set rows to Input
KEYPAD_PORT_COLS&=0x0F;//pull down the columns
KEYPAD_DDR_COLS|=0xF0;// Set columns to Output
_delay_ms(2);//give delay of 2ms
rows=0x0F&(~(KEYPAD_PIN_ROWS &0x0F));// read the value of rows
/* value of columns and rows will be 1,2,4,8
we will convert it to 0,1,2,3 using keypad_tbl1*/
// we will convert it to 0,1,2,3 using keypad_tbl1*/
temp = (keypad_tbl1[columns]) + (keypad_tbl1[rows]<<2);
return key;
Task 2: Simulation
4 [Document title]