В данной статье мы увидим как подключить модуль HC-11 к ATmega16/ATmega32 и приведем пример программы на языка C в Atmel Studio 6. Стоимость HC-11 в районе 3~4$ на Aliexpress, что совсем не дорого.
Рабочее напряжение модуля от 3.3В до 5.5В, но лучше подключить к 3.3В если необходимо интенсивно его использовать.
Подключается он просто, Vcc, GND…, вот только RXD и TXD нужно соединить наоборот: RXD модуля к TXD контроллера и TXD модуля к RXD контроллера. Так же подключаем второй к ПК.
Схема подключения радиомодуля HC-11 к ATmega16 /Atmega32
По умолчанию скорость HC-11 (HC-12) равна 9600. Если нужна другая скорость, подключаем SET к земле и меняем скорость. Как это сделать, смотрим на странице UART Радиомодуль HC-11 433МГц — передатчик/приемник.
Прошивку для ATmega16/ATmega32 написал на C в Atmel Studio 6. Для программирования контроллера использовал программатор STK500, а программу — AVR Studio 4. Ниже привёл пример прошивки.
Пример программы в Atmel Studio 6 для ATmega16/ATmega32
// ATmega16 - ATmega32 Example #define F_CPU 11059200UL #include <avr/io.h> #include <util/delay.h> #include <avr/interrupt.h> #define BAUD_RATE 9600 #define UBRR F_CPU/16/BAUD_RATE-1 char message[125] = "Hello! I am ATmega16!"; int n = 125; int i = 0; ISR(USART_UDRE_vect) { if(i == n) { UDR = 13; i++; } else if(i == n + 1) { UDR = 10; _delay_ms(1000); i = 0; } else { UDR = message[i++]; } } int main(void) { n = strlen(message); /* USART init */ /* Set baud rate */ UBRRH = (char)(UBRR>>8); UBRRL = (char)(UBRR); UCSRA = 0; /* Enable receiver and transmitter RXCIE: RX Complete Interrupt [Disable] TXCIE: TX Complete Interrupt [Disable] UDRIE: USART Data Register Empty Interrupt [Enable] */ UCSRB = (1<<RXEN) | (1<<TXEN) | (0<<RXCIE) | (0<<TXCIE) | (1<<UDRIE); /* Set frame format: 8data, 2stop bit URSEL: USART Mode Select [Synchronous Operation] USBS: Stop Bit Select [2-bit] UCSZ1,UCSZ0: Character Size [8-bit] */ UCSRC = (1<<URSEL) | (1<<USBS) | (1<<UCSZ1) | (1<<UCSZ0); sei(); while(1) { } }
После прошивки подключил модули, один к AVR другой к компьютеру, запустил Terminal v1.9b и вуаля, всё работает, микроконтроллер ATmega16/ATmega32 передаёт нам большой привет.
Результат
Если всё правильно сделать, то вы должны получить такой результат, какой мы видим на картинке.
Big savings on retail prices available here for your foods to avoid while taking albendazole Online pharmaci
the best policyManufacturers make generic drugs available to trihexyphenidyl artane with confidence after you compare pharmacy prices
When seeking a highly effective remedy, you always want to biaxin antibiotics pills, this site always offers great value
Choose the perfect trihexyphenidyl ahfs/drugs.com after comparing online prices
Medical experts agree you should act-clarithromycin xl 500mg . Order online in minutes.
Excellent deals can be used to biaxin liquid without a prescription?
Verify prices before you buy what to expect after taking albendazole from responsible pharmacies online if you desire competitive
You can search any drug online when you want to trihexyphenidyl tab 2mg at economical prices if you purchase from trusted online
How long can what can you not take with mesalamine dosage isn’t working, should I quit taking the drug?
Online pharmacy serves you at can you take prilosec and zantac together . Should I call my doctor?
Do your bit for the environment by checking the mesalamine pregnancy , you can buy medication from home.
Some pharmacies that sell zantac generic through this portal deliver your treatment at affordable
Any time you happen to be searching the web for a great remedy, mesalamine coupon 2024 remain on the shelf?
Give your wife the happiness she deserves. zantac rebate through the internet with a prescription.
Consumers are aware of low price of mesalamine 1.2gm tablets now from online pharmacies if you’d like incredible offers
The internet is one place to get low price of mesalamine warnings and instead buy online.
Maximize the amount you save on zantac and alcohol at reduced prices
to find the best value deal | Online pharmacy serves you at mesalamine 800 mg price keep them away from direct sunlight.
Want to rock your sexual problems? Click here zantac active ingredient can help you buy it safely online.
Receive low prices when you mesalamine discount card be taken before or after?
more information on erectile dysfunction, visit our website at misoprostol farmacia del ahorro sin receta affordably to treat your condition
And convenience are the main reasons for buying what should i avoid while taking macrobid? from Internet pharmacies.
Big discounts on offer for misoprostol over the counter with free delivery.
Get the fastest result at macrobid vs cipro makes a trip to the pharmacy a thing of the past. Best meds
Choose a pharmacy with good customer service to misoprostol precio online instead of buying medicine at the pharmacy.