极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 23999|回复: 4

LGT8F328 在 arduino 內使用 S檔案範例

[复制链接]
发表于 2020-4-28 18:57:05 | 显示全部楼层 |阅读模式
本帖最后由 eddiewwm 于 2020-4-28 19:11 编辑

LGT8F328 在 arduino 內使用 S檔案的做法:
1) 先把 S檔案寫好,在此以 blink.S 作範例:
  1. #define __SFR_OFFSET 0
  2. #include <avr/io.h>         

  3. .section .text
  4. .global setIO ; << This exports the function name
  5. .global blink ; << This exports the function name

  6. setIO:    ; << This is the name of the function
  7.   ldi r18, 0x20   ; loading 0x20 = 00100000 into register r18
  8.   out DDRB, r18   ; making pin 5 of port B an output
  9.   ret;
  10.   
  11. blink:  ldi r18, 0x00   ; loading 0x20 = 00100000 into register r18
  12.   out PORTB, r18   ; pin 5 of port B output Low
  13.   ldi r18, 0x20   ; loading 0x20 = 00100000 into register r18
  14.   out PORTB, r18   ; pin 5 of port B output High
  15.   ret;
  16.   
复制代码


2) 在 arduino ino檔內宣告相關的副程序並呼叫使用
  1. extern "C" void setIO(); // << Add the "C" to tell it not to munge the name
  2. extern "C" void blink(); // << Add the "C" to tell it not to munge the name

  3. void setup() {
  4.   // put your setup code here, to run once:
  5.   setIO();
  6. }

  7. void loop() {
  8.   // put your main code here, to run repeatedly:
  9.   blink();
  10. }
复制代码


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复

使用道具 举报

发表于 2020-5-3 21:04:19 | 显示全部楼层
什么叫S档案?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-5-6 12:14:18 | 显示全部楼层

簡單說,即是匯編源碼檔。
回复 支持 反对

使用道具 举报

发表于 2020-5-17 09:18:18 | 显示全部楼层
敢问先生LGT8F328P有没有操作FLASH的库?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-5-17 15:17:02 | 显示全部楼层
microplc 发表于 2020-5-17 09:18
敢问先生LGT8F328P有没有操作FLASH的库?

沒看到 LGT 有提供操作 FLASH 的庫。
在 LGT 交流群中有以下一個範例,你可參考看看是否用得著。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-4-25 02:02 , Processed in 0.064342 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表