Essays.club - Получите бесплатные рефераты, курсовые работы и научные статьи
Поиск

ASCII code in microcontrollers Aim

Автор:   •  Сентябрь 29, 2025  •  Лабораторная работа  •  530 Слов (3 Страниц)  •  43 Просмотры

Страница 1 из 3

Laboratory work №2

Using the ASCII code in microcontrollers Aim

  • Improving skills on microcontroller programming
  • Practicing work with I/O systems,
  • studying <util/delay.h> library

Task

Transfer to the controller the binary ASCII code of a capital letter of your surname in Latin, by using the two buttons on the debug board. The SW0 button passes bit "0", SW1 passes bit "1", SW2 reset input, at the same time each entered bit has to be followed single short, and reset - long inclusion of light-emitting diodes of LED0 and LED1. At the right entered code the controller has to bring light-emitting diodes a LED0 and LED1 series out of three short impulses, and at incorrect input a series out of three long impulses. Libraries to use:

<avr/io.h>, <util/delay.h>

Tools description

Atmel Studio is the integrated development platform (IDP) for developing and debugging Atmel® SMART ARM®-based and Atmel AVR® microcontroller (MCU) applications. Atmel Studio supports all AVR and Atmel SMART MCUs. The Atmel Studio 7 IDP gives you a seamless and easy-to-use environment to write, build and debug your applications written in C/C++ or assembly code. It also connects seamlessly to Atmel debuggers and development kits.

Proteus 7.0 is a Virtual System Modeling (VSM) that combines circuit simulation, animated components and microprocessor models to co-simulate the complete microcontroller based designs.

ATmega2561 is the high-performance, low-power Atmel 8-bit AVR RISC-based microcontroller combines 256KB ISP flash memory, 8KB SRAM, 4KB EEPROM, 86 general purpose I/O lines, 32 general purpose working registers, real time counter, six flexible timer/counters with compare modes, PWM, 4 USARTs, byte oriented 2-wire serial interface, 8-channel 10-bit A/D converter, and a JTAG interface for on-chip debugging. The device achieves a throughput of 16 MIPS at 16 MHz and operates between 4.5-5.5 volts.

Progress of work

  1. Start the atmel studio

[pic 1]

  1. Create a new GCC C executable project

[pic 2]

  1. Select the device (in our case it’s ATmega2561)

[pic 3]

  1. Next we do coding:

Initially you have to define what is the hex value of your name in ASCII from the table and convert it to binary. (Ex: N has hexadecimal code 4E, in binary it is 1001110) We will declare this value in a constant with the name CODE_LETTER

#include <avr/io.h> #define F_CPU 1000000UL #include <util/delay.h>

// N in ASCII: 0x4E 01001110 #define CODE_LETTER 0b01001110

void dash(void){

PORTC = 0x03;

_delay_ms(400);

PORTC = 0x00;

_delay_ms(50);

...

Скачать:   txt (3.8 Kb)   pdf (818.4 Kb)   docx (730.4 Kb)  
Продолжить читать еще 2 страниц(ы) »
Доступно только на Essays.club