ATtiny202 How to create program more readable?

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am stuck on how to make program more readable by separating functional blocks (e.g. USART, RTC, TCB ...) into separate program files (*.c/*.h) and link them to the main program file. Any suggestion for program example how to do it?

I started with creating avr-main.c file:

 

/*
 * File:   main.c
 * Author: Dan
 *
 * Created on January 29, 2021, 8:43PM
 */

#include <avr/io.h>

int main(void) {
    /* Replace with your application code */
    while (1) {
    }
}

MPLAB X IDE, XC8 and Standalone Project for ATtiny202

Last Edited: Sat. Jan 30, 2021 - 12:35 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

+1

 

Also: http://c-faq.com/decl/decldef.html

 

Note that this has nothing specifically to do with ATtiny202 or  MPLAB X - this is all standard 'C' stuff.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Sat. Jan 30, 2021 - 12:21 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Note that the basic ideas for managing large projects work very well for smaller ones. It is really not an issue of project size except that, for smaller ones, it tends to be voluntary while large ones almost force you.

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ah yes - you can see that it's based on the tutorial Jim posted

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...