;
// Clear the flag
UCSR0A = (1 << TXC0);
}
int
main(
void
)
{
// PORTB5 to output
DDRB = (1 << 5);
// LED OFF
PORTB = 0;
led_on = 0;
// Enable Pin-change interrupt
PCICR = (1 << PCIE0);
PCMSK0 = (1 << PCINT7);
// USART0
// Baud trivial in synchronous mode
UBRR0 = 0x0FFF;
// Enable XCK for master clock outout
DDRD |= (1 << 4);
// Enable USART transmitter
UCSR0B |= (1 << TXEN0);
// Synchronous mode
UCSR0C |= (1 << UCSZ01) | (1 << UCSZ00) | (1 << UMSEL00);
// Interrupts on
sei();
while
(1) {
// Sleep
set_sleep_mode(SLEEP_MODE_IDLE);
sleep_mode();
// Woken up
if
(send_message) {
// Send a message
const
char
* pmessage;
if
(led_on)
pmessage = message_on;
else
pmessage = message_off;
while
(*pmessage)
usart_send(*p+);
// Send the ticker value
usart_send(
'0'
);
usart_send(
'\n'
);
// Sent
send_message = 0;
}
}
}
To do:
• Build the project/solution (F7)
• Program the application into the target device using Start Without Debugging (Ctrl+Alt+F5)
• Switch to Data Visualizer to see the results
3.1.13.1 Enable USART Interface
To do:
• Check the
USART
checkbox
• Open the
USART Configuration
dialog by pushing the gear button next to the
USART
checkbox
Power Debugger
Detailed Use Cases
©
2020 Microchip Technology Inc.
User Guide
DS40002201A-page 27