2264 views|4 replies

373

Posts

0

Resources
The OP
 

[ATmega4809 Curiosity Nano Review] Serial port application preliminary: printing sine string through serial port [Copy link]

I have been busy with the CAN bus project recently, so I haven't updated the ATMEGA4809 related updates in time. Now I have updated some basic things in the forum, hoping that it will be of some help to everyone.

I believe that everyone has already mastered some basic operations by reading other great posts, so here I will directly post some of my tests here. Later, I will post some posts about the combination of CAN bus and ATMEGA4809, and I hope it will be helpful to everyone.

For serial port applications, the pins should be correctly configured, as shown in the following figure

You still have to choose PB0 and PB1 as the built-in serial ports. In addition, you can choose PF5 as the LED that works synchronously with the serial port to display the corresponding information to prove that your program is running normally.

In addition, relevant settings should be made in the pin option interface, as shown below

Since today we are only introducing the sending test, I will only check one item.

After the basic settings are completed, you can write the program in the main program:


#include "mcc_generated_files/mcc.h"
#include <stdio.h>
/*
Main application
*/
uint8_t volt[16]={10,14,18,22,26,30,34,38,40,38,34 ,30,26,22,18,14};
uint8_t displayvolt[20];
int main(void)
{
uint8_t a,b,c,d,e,f;
b=0;
//e=1;
c=1 ;
/* Initializes MCU, drivers and middleware */
SYSTEM_Initialize();

/* Replace with your application code */
while (1)
{
for(a=0;a<20;a++)
{ displayvolt[a]=volt;
b++;
if(b>=16)
b=0;
printf("displayvolt[%d]",a);
for(c=0;c<displayvolt[a];c++)
{ printf("*"); }
printf("\n");
}
//DELAY_milliseconds( 100);;
}
}

This is just a basic program that uses the serial port to print a sine string. The effect is as follows:

If you rotate the image counterclockwise, it will be a sine wave.

I hope this is helpful to beginners. If you are an expert, please skip this article.


This content was originally created by desk1983 , a user on the EEWORLD forum. If you want to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source.

image.png (57.86 KB, downloads: 0)

image.png
This post is from Microchip MCU

Latest reply

When printing the serial number, the digits have 1 and 2 digits, which causes the output to vary. If they are aligned, it will be perfect.   Details Published on 2019-12-11 12:11
Personal signature很高兴认识大家,请多关照
 

373

Posts

0

Resources
2
 

Be your own sofa

This post is from Microchip MCU
 
Personal signature很高兴认识大家,请多关照
 
 

9702

Posts

24

Resources
3
 
Looks more like a triangle wave
This post is from Microchip MCU
 
 
 

1w

Posts

25

Resources
4
 

When printing the serial number, the digits have 1 and 2 digits, which causes the output to vary. If they are aligned, it will be perfect.

This post is from Microchip MCU

Comments

Well, I will post some new summaries later, I hope it will be helpful to everyone.  Details Published on 2019-12-13 08:23
 
 
 

373

Posts

0

Resources
5
 
dcexpert posted on 2019-12-11 12:11 When printing serial numbers, the numbers have 1 and 2 digits, which causes the output to change. If they are aligned, it will be perfect.

Well, I will post some new summaries later, I hope it will be helpful to everyone.

This post is from Microchip MCU
 
Personal signature很高兴认识大家,请多关照
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list