# fpc-avr
A collection of Free Pascal AVR microcontroller code snippets, examples and libraries.
# Structure
## src folder
### bin
A Linux-64 bit compiled gdb 8.0 for avr, includes patch for debugging program memory.
### examples
| Name | Description |
| :--- | :--- |
| blink1 | A simple blink example using busy delay functions. |
| blink2 | A simple timer interrupt driven blink example. |
| blink4809 | A simple blink example using busy delays to test the megaAVR0 series code. |
| blinktiny10 | A simple blink example using a timer interrupt, for the attiny10 controller. |
| blinktiny10 | A simple blink example using a timer interrupt, for the attiny104 controller. |
| blinktiny15 | A simple blink example using a timer interrupt, for the attiny15 controller which doesn't have any RAM. |
| dumptiny104flash | A program to dump flash contents to serial. Written to investigate a [potential hardware bug](https://www.avrfreaks.net/forum/critical-hardware-bug-attiny102-and-attiny104)
| i2c | Reads the time from a DS1307 real time clock over i2c. |
| intmathtest | Testing of assembler versions of integer division algorithms in the integermath library. |
| light_tracker | A simple fun project that uses a light sensor mounted on a servo driven pan & tilt base to track a light source. |
| lcd1 | A simple sliding text example for HD44780 compatible character LCDs. |
| lcd2-progmem | Show bitmap and sliding text on PCD8544 compatible LCD. Also shows how to load a glyph from flash memory. |
| uart1 | A simple serial echo example. |
| simavrtest | Demonstrates how to pass information to simavr using .mmcu section. |
| sound | A sound (noise) generator using simple formulas. Demonstrated on an attiny10. |
| uart1 | A simple serial test that reads a character and echos its ordinal value. |
| uart4809 | A simple test written mostly to figure out how to read a button press, generate timer interrupts and send data over serial on the atmega4809. |
### rtl-avr-modifications
This folder contains "improved" implementations for the AVR. Main changes include the exclusion of exception raising code and some assembler routines which are more compact than the generic Pascal implementations in rtl/inc/generic.inc.
### scripts
A collection of scripts useful for debugging.
### tests
This folder contains test cases for various changes to the rtl, bugs in the compiler, etc.
# Compiling
## AVR cross compiler
Refer to [Building cross-compiler](http://wiki.freepascal.org/AVR#Building_cross-compiler) for tips.
## Compiling examples
An easy way to compile an example is to open the lazarus project file in the lazarus subfolder in the example.
This will open the example in Lazarus and all required options to compile the example will be configured, except the path to the AVR cross compiler.
To configure Lazarus to use the cross compiler for the project, open _Project Options_ (ctrl + shift + F11), go to _Compiler Commands_ and enter path to cross compiler executable.
Another way that doesn't require Lazarus is to use a compile script, for example on Linux:
```
#!/bin/sh
~/fpc/3.1.1/compiler/ppcrossavr -Tembedded -Wpatmega328p -Cpavr5 -Pavr -O3 -g -a -al -XPavr- -Fu"../../library" -Sm -dF_CPU:=16000000 $1
```
This script needs to be executed from the base folder of an example, to ensure the relative path to the library is valid. The name of the example project should be passed to the script as a parameter e.g. sh compile.sh blink1.pp.
An equivalent batch file for Windows could be as follows (untested):
```
[substitute your path to fpc compiler folder here]\ppcrossavr.exe -Tembedded -Wpatmega328p -Cpavr5 -Pavr -O3 -g -a -al -XPavr- -Fu"..\..\library" -Sm -dF_CPU:=16000000 $1
```
Explanation of required and useful compiler options:
* -Sm - enable macro support, required to pass the -dF_CPU as command line parameter to the compiler.
* -dF_CPU - the clock frequency of the target mcu (by convention the F_CPU define is expected wherever the mcu clock speed is required.
* -Fu"../../library" - path to library folder.
* -O3 - optional optimization flag, usually results in smaller code (which is a good thing).
* -a - optional, do not delete generated assembler files
* -al - optional, list source code lines in assmebler file
没有合适的资源?快使用搜索试试~ 我知道了~
免费的 Pascal AVR微控制器项目_Pascal_代码_相关文件_下载
共113个文件
lpi:34个
pp:27个
pas:20个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 180 浏览量
2022-07-08
01:32:23
上传
评论
收藏 2.4MB ZIP 举报
温馨提示
Free Pascal AVR 微控制器代码片段、示例和库的集合。 结构 src 文件夹 垃圾桶 用于 avr 的 Linux-64 位编译的 gdb 8.0,包括用于调试程序内存的补丁。 例子 姓名 描述 眨眼1 一个使用繁忙延迟函数的简单闪烁示例。 眨眼2 一个简单的定时器中断驱动闪烁示例。 眨眼4809 一个使用繁忙延迟测试 megaAVR0 系列代码的简单闪烁示例。 眨眼10 一个使用定时器中断的简单闪烁示例,用于 attiny10 控制器。 眨眼10 一个使用定时器中断的简单闪烁示例,用于 attiny104 控制器。 眨眼15 一个使用定时器中断的简单闪烁示例,用于没有任何 RAM 的 attiny15 控制器。 dumptiny104flash 将闪存内容转储到串行的程序。写来调查一个潜在的硬件错误 i2c 通过 i2c 从 DS1307 实时时钟读取时间。 智力测验 在 integermath 库中测试整数除法算法的汇编版本。 等等等等 更多详情、使用方法,请下载后阅读README.md文件
资源推荐
资源详情
资源评论
收起资源包目录
免费的 Pascal AVR微控制器项目_Pascal_代码_相关文件_下载
(113个子文件)
hello_world-mega2560.bin 5KB
hello_world-uno.bin 3KB
hello_world-mega2560.elf 21KB
hello_world-uno.elf 13KB
blink.elf 7KB
.gitignore 181B
hello_world-mega2560.hex 13KB
hello_world-uno.hex 9KB
LICENSE 16KB
readHX711.lpi 5KB
blink.lpi 5KB
sound.lpi 5KB
mpu6050test.lpi 4KB
i2ctest.lpi 4KB
mpu6050pantilt.lpi 4KB
blink.lpi 3KB
adctest.lpi 3KB
LCDtest.lpi 3KB
dumpflash.lpi 3KB
light_tracker.lpi 3KB
LCDtest.lpi 3KB
uarttest.lpi 3KB
blink.lpi 3KB
blink.lpi 3KB
LCDtest.lpi 3KB
intmathtest.lpi 3KB
hello_world.lpi 3KB
blink.lpi 3KB
blink.lpi 3KB
simavrtest.lpi 2KB
multest.lpi 2KB
divmodtest.lpi 2KB
progmemtest.lpi 2KB
uart1.lpi 2KB
test.lpi 2KB
test.lpi 2KB
test.lpi 2KB
test.lpi 2KB
test.lpi 2KB
test.lpi 2KB
test.lpi 2KB
test.lpi 2KB
test.lpi 2KB
light_tracker.lpr 3KB
sound.lpr 2KB
simavrtest.lpr 2KB
blink.lpr 1KB
blink.lpr 822B
blink.lpr 646B
README.md 4KB
readme.md 1KB
README.md 1KB
README.md 1014B
readme.md 639B
readme.md 455B
README.md 426B
README.md 211B
readme.md 178B
mpu6050.pas 45KB
lcd_pcd8544.pas 11KB
i2c.pas 11KB
spi.pas 8KB
lcd_hd44780.pas 7KB
integermath.pas 7KB
uart.pas 6KB
i2cbitbang.pas 5KB
delay.pas 4KB
dummyunit.pas 3KB
simplemath.pas 3KB
simavr.pas 3KB
lcd_config.pas 2KB
progmem.pas 961B
hello_world.pas 751B
lcd_config.pas 678B
lcd_config.pas 678B
spi_config.pas 590B
spi_config.pas 590B
spi_config.pas 589B
target-subarch-abi.patch 8KB
LDR_sensor_circuit.png 10KB
mpu6050test.pp 6KB
mpu6050pantilt.pp 5KB
i2ctest.pp 5KB
divmodtest.pp 4KB
intmathtest.pp 4KB
adctest.pp 3KB
test.pp 3KB
readHX711.pp 3KB
uarttest.pp 3KB
LCDtest.pp 3KB
LCDtest.pp 3KB
dumpflash.pp 2KB
blink.pp 955B
LCDtest.pp 915B
progmemtest.pp 705B
test.pp 600B
multest.pp 599B
uart1.pp 497B
blink.pp 422B
test.pp 378B
共 113 条
- 1
- 2
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9156
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功