一乐电子

一乐电子百科

 找回密码
 请使用微信账号登录和注册会员

QQ登录

只需一步,快速开始

快捷登录

手机号码,快捷登录

搜索
楼主: zyh555
收起左侧

新版晶体管测试器AVR-Transistortester

  [复制链接]
发表于 2013-7-20 20:09 | 显示全部楼层
我做的是9V电压的版本,用论坛李老师的单节锂电池的升压板子供电。下周上个测试图。
发表于 2013-7-21 13:29 | 显示全部楼层
adsl_95 发表于 2013-7-20 19:34
我也分數字吧.

1.供電問題.

不客气,互相学习!
1、M8的供电电压是5V,但是可以参考一下前面发的标准电路,原设计是用9V的叠层电池供电,用低压差稳压器降到5V给单片机供电。
    所以有很多设置都与此有关。 比如说I/O口禁用上拉电阻,电池检测、自动关机等。
     无自动开关机的电路就是直接给M8供+5V了。至于直接用9v给单片机供电估计只有给单片机收尸了。

2、 假设无电电压为XV,则告警电压为:  
        无电设置电压       告警电压
        X >5.3V            X+0.8V
        5.3>=X>2.9      X+0.4V
        2.9>=X>1.3      X+0.2V
        1.3>X               X+0.1V
        当检测电压低于告警电压时液晶屏上会显示告警,当低于无电电压时程序会报警后自动关机。

3、ponyprog程序见过,但是没有用过。
    编程器对单片机编程都差不多,主要是看编程器支持所用芯片。一般程序是设置编程芯片型号、调入程序文件,芯片擦除查空、编程芯片、编程熔丝位。
    写入程序后不编程熔丝位会导致程序运行偏慢,因为默认为RC振荡1MHz。但是程序应该会对二极管和电阻正常检测。如正常后再编程熔丝位就可以了。
发表于 2013-7-21 19:15 | 显示全部楼层
m8晶体.jpg
发表于 2013-7-21 22:39 | 显示全部楼层
本帖最后由 adsl_95 于 2013-7-21 22:45 编辑
wumaoxu 发表于 2013-7-21 13:29
不客气,互相学习!
1、M8的供电电压是5V,但是可以参考一下前面发的标准电路,原设计是用9V的叠层电池 ...

您才客氣了.呵呵.

1.
果然我想法沒錯哈,取消的話使用5V才是對的.但這樣的話,電壓檢測就不能用了吧?
因為電源接入只有7805出來的5V了.沒有那一堆電路了,所以電壓檢測根本無法檢測鋰電池那端吧?

2.
用5V輸入上拉電阻還用裝麼?我的感覺應該還是得用才對.

3.關於熔絲位有個問題.
第一次折騰M8,沒太弄明白.
設置時候怎麼搞呢?是直接填入L:0X3F   H:0XC9這樣子?
還是那些熔絲位一個個點自己改?
看著像是16進制的內存值一樣..........能給一張使用外部晶振的熔絲設定圖片嗎?怕自己搞錯了廢掉M8............
還有個問題,就是第二次搞熔絲位,還用不用先接串口在通電?
一般不都是說第一次不接燒寫數據線默認會運行程序麼...........
第一次聽說可以分開的哈.孤陋寡聞了.

发表于 2013-7-22 19:15 | 显示全部楼层
adsl_95 发表于 2013-7-21 22:39
您才客氣了.呵呵.

1.


1、电池检测还是可以用的,可以通过电阻分压接到7805的输入端。分压电阻可以用默认的10K、3.3K,这样最高输入电压约15V,可以满足需要。
     无电电压可以设的稍微低点,主要是可以在测试时显示电池电压,这样用起来比较方便。

2、用5V电压仍然需要上拉电阻,除非修改makefile文件后编译一下。而且原来的单片机工作电压就是5V。

3、从网上找了一个小马的教程,可以参考一下。从文章看,编程熔丝位需要看每位的定义,这个不如别的软件方便。
    而且好像程序和熔丝位是一块编程的。这样可以先光烧写程序,熔丝位保持默认,上机试过后再重新编程程序和熔丝位。注意需要检查默认熔丝位是否正确。
    你可以下一个智峰的progisp软件看看熔丝位的设定,这个比较方便。
    http://wenku.baidu.com/view/3b4b0140a8956bec0975e3b1.html
发表于 2013-8-2 21:44 | 显示全部楼层
本帖最后由 adsl_95 于 2013-8-2 21:56 编辑
wumaoxu 发表于 2013-7-22 19:15
1、电池检测还是可以用的,可以通过电阻分压接到7805的输入端。分压电阻可以用默认的10K、3.3K, ...

你好,現在程序都編譯好了,熔絲位我查了很多資料...........
但還是不知道該怎麼弄,你能用小馬給我弄個截圖嗎?還是照貓畫虎比較保險,弄不好直接單片機浮雲...........
那教只是說熔絲位選項在哪以及如何操作,至於M8程序的熔絲位,不知道怎麼設置,自己胡來肯定死得很慘..........
我現在不知道該如何操作熔絲位了,求指點.謝謝.難道和那教程裏的一樣的熔絲位?不會吧............
這個數值到底如何使用現在是難住我了............
現在關鍵是你本帖裏設置熔絲位的截圖使用外置晶振的一張也沒有,沒有任何可參考的..............那高低熔絲位的數值,看圖,我用這個值可以算出來.但看選擇的名稱,你妹都不一樣怎麼辦..............
求截圖,謝謝.




PS:
電壓基準弄到了淩力爾特的LTC6655-2.5.........
0.025%精度給他是不是很浪費............


PS2:
如果你有支持串口更好的下載軟件可以推薦.小馬確實不怎麼易用,還沒漢化............
我剛用小馬測試,使用串口連接OK沒出錯.我還是用虛擬機映射串口居然都沒問題,哈哈.

截图185.png
截图184.png
发表于 2013-8-3 09:27 | 显示全部楼层
本帖最后由 wumaoxu 于 2013-8-3 09:52 编辑
adsl_95 发表于 2013-8-2 21:44
你好,現在程序都編譯好了,熔絲位我查了很多資料...........
但還是不知道該怎麼弄,你能用小馬給我弄個截 ...

1、汉化版的小马2000: http://www.ddooo.com/softdown/7399.htm

2、小马的使用教程:http://wenku.baidu.com/view/dbaa84f24693daef5ef73d04.html
                           http://wenku.baidu.com/view/29af4cdc5022aaea998f0f1a.html

3、按照教程,选中熔丝位为编程。附图为两个软件的熔丝位对照。
无标题.jpg

4、关于电压基准确实有点大材小用了。个人觉得这个晶体管测试仪想要精度高一些需要对电源、电阻下点功夫。
    然后就是研究makefile文件,里面有很多的参数可以修改。

5、关于串口的软件我也不清楚。我在单位上用的是EasyPRO 80B,家里是自己做的USBISP,对于AVR单片机感觉USBISP更好用一点。

发表于 2013-8-3 09:35 | 显示全部楼层
没事在压缩包中乱找,发现了几个东西:
Front.jpg
Top.jpg
无标题1.jpg
ComponentTester-HW-1.00m.rar (303.74 KB, 下载次数: 769)



Schematics.pdf

56.75 KB, 下载次数: 723, 下载积分: 一乐金币 -1

发表于 2013-8-4 20:33 | 显示全部楼层
本帖最后由 adsl_95 于 2013-8-4 22:20 编辑

编辑掉,已经解决了............正常使用中..............
发表于 2013-8-5 21:27 | 显示全部楼层
wumaoxu 发表于 2013-8-3 09:27
1、汉化版的小马2000: http://www.ddooo.com/softdown/7399.htm

2、小马的使用教程:http://wenku.ba ...

昨天用串口燒錄失敗,延長線太長,不得已把機箱搬了下來用並口,燒寫,成了.
現在有個疑問.我開機檢測電壓顯示13V,萬用表測量是12.5V......難道這個沒法精確到小數點後面嗎?
電壓報警檢測代碼那我這樣改的,對麼?

###############################################################################
# Makefile for the project TransistorTester
###############################################################################

## General Flags
PROJECT = TransistorTester
TARGET = TransistorTester.elf
CC = avr-gcc

CPP = avr-g++

CFLAGS = -Wall

# ********************** 脛nderbare Flags zur Configuration des Transistortesters
# ********************** config options for your Semiconductor tester
# Every changing of this Makefile will result in new compiling the whole
# programs, if you call make or make upload.

# Select your Part-No. for avrdude :
# atmega8  : m8
# atmega168: m168 or m168p
# atmega328: m328 or m328p
PARTNO = m8

# Select your language:
# Available languages are: LANG_ENGLISH, LANG_GERMAN, LANG_POLISH, LANG_CZECH, LANG_SLOVAK, LANG_SLOVENE,
#                          LANG_DUTCH, LANG_BRASIL,  LANG_RUSSIAN
UI_LANGUAGE = LANG_ENGLISH

# The LCD_CYRILLIC option is necessary, if you have a display with cyrillic characterset.
# This lcd-display don't have a character for Ohm and for 碌 (micro).
# Russian language requires a LCD controller with russian characterset and option LCD_CYRILLIC!
#CFLAGS += -DLCD_CYRILLIC

# Option STRIP_GRID_BOARD selects different board-layout, do not set for standard board!
# The connection of LCD is totally different for both versions.
#CFLAGS += -DSTRIP_GRID_BOARD

# The WITH_SELFTEST option enables selftest function (only for mega168 or mega328).
#CFLAGS += -DWITH_SELFTEST

# AUTO_CAL will enable the autocalibration of zero offset of capacity measurement and
# also the port output resistance values will be find out in SELFTEST section.
# With a external capacitor a additionally correction of reference voltage is figured out for
# low capacity measurement and also for the AUTOSCALE_ADC measurement.
# The AUTO_CAL option is only selectable for mega168 and mega328.
#CFLAGS += -DAUTO_CAL

# FREQUENCY_50HZ enables a 50 Hz frequency generator for up to one minute at the end of selftests.
#CFLAGS += -DFREQUENCY_50HZ


# The WITH_AUTO_REF option enables reading of internal REF-voltage to get factors for the Capacity measuring.
CFLAGS += -DWITH_AUTO_REF

# REF_C_KORR corrects the reference Voltage for capacity measurement (<40uF) and has mV units.
# Greater values gives lower capacity results.
CFLAGS += -DREF_C_KORR=4

# REF_L_KORR corrects the reference Voltage for inductance measurement and has mV units.
CFLAGS += -DREF_L_KORR=40

# C_H_KORR defines a correction of 0.1% units for big capacitor measurement.
# Positive values will reduce measurement results.
CFLAGS += -DC_H_KORR=5

# The WITH_UART option enables the software UART  (TTL level output at Pin PC3, 26).
# If the option is deselected, PC3 can be used as external voltage input with a
# 10:1 resistor divider (only without the BAT_CHECK option for ATmega8).
#CFLAGS += -DWITH_UART

# The CAP_EMPTY_LEVEL  defines the empty voltage level for capacitors in mV.
# Choose a higher value, if your Tester reports "Cell!" by unloading capacitors.
CFLAGS += -DCAP_EMPTY_LEVEL=4

# The AUTOSCALE_ADC option enables the autoscale ADC (ADC use VCC and Bandgap Ref).
#CFLAGS += -DAUTOSCALE_ADC
#CFLAGS += -DREF_R_KORR=0

# The ESR_ZERO value define the zero value of ESR measurement (units = 0.01 Ohm).
CFLAGS += -DESR_ZERO=29

# NO_AREF_CAP tells your Software, that you have no Capacitor installed at pin AREF (21).
# This enables a shorter wait-time for AUTOSCALE_ADC function.
# A capacitor with 1nF can be used with the option NO_AREF_CAP set.
CFLAGS += -DNO_AREF_CAP

# The OP_MHZ option tells the software the Operating Frequency of your ATmega.
OP_MHZ = 8
#OP_MHZ = 1

# The USE_EEPROM option specify where you wish to locate fix text and tables.
# If USE_EEPROM is unset, program memory (flash) is taken for fix text and tables.
CFLAGS += -DUSE_EEPROM

# Setting EBC_STYPE will select the old style to present the order of Transistor connection (EBC=...).
# Omitting the option will select the 123=... style.  Every point is replaced by a character identifying
# type of connected transistor pin (B=Base, E=Emitter, C=Collector, G=Gate, S=Source, D=Drain).
# If you select EBC_STYLE=321 , the style will be 321=... , the inverted order to the 123=... style.
#CFLAGS += -DEBC_STYLE

# Setting of NO_NANO avoids the use of n as prefix for Farad (nF), the mikro prefix is used insted (uF).
# CFLAGS += -DNO_NANO

# The PULLUP_DISABLE option disable the pull-up Resistors of IO-Ports.
# To use this option a external pull-up Resistor (10k to 30k)
# from Pin 13 to VCC must be installed!
CFLAGS += -DPULLUP_DISABLE

# The ANZ_MESS option specifies, how often an ADC value is read and accumulated.
# Possible values of ANZ_MESS are 5 to 200 .
CFLAGS += -DANZ_MESS=44


# The POWER_OFF option enables the power off function, otherwise loop measurements infinitely
# until power is disconnected with a ON/OFF switch (CFLAGS += -DPOWER_OFF).
# If you have the tester without the power off transistors, you can deselect POWER_OFF .
# If you have NOT selected the POWER_OFF option with the transistors installed,
# you can stop measuring by holding the key several seconds after a result is
# displayed. After releasing the key, the tester will be shut off by timeout.
# Otherwise you can also specify, after how many measurements without found part
# the tester will shut down (CFLAGS += -DPOWER_OFF=5).
# The tester will also shut down with found part,
# but successfull measurements are allowed double of the specified number.
#  You can specify up to 255 empty measurements (CFLAGS += -DPOWER_OFF=255).
#CFLAGS += -DPOWER_OFF=5
#CFLAGS += -DPOWER_OFF

# Option BAT_CHECK enables the Battery Voltage Check, otherwise the SW Version is displayed instead of Bat.
# BAT_CHECK should be set for battery powered tester version.
CFLAGS += -DBAT_CHECK

# The BAT_OUT option enables Battery Voltage Output on LCD (if BAT_CHECK is selected).
# If your 9V supply has a diode installed, use the BAT_OUT=600 form to specify the
# threshold voltage of your diode to adjust the output value.
# This threshold level is added to LCD-output and does not affect the voltage checking levels.
CFLAGS += -DBAT_OUT=150

# To adjust the warning-level and poor-level of battery check to the capability of a
# low drop voltage regulator, you can specify the Option BAT_POOR=5400 .
# The unit for this option value is 1mV , 5400 means a poor level of 9.9V.
# The warning level is 0.8V higher than the specified poor level (>9.5V).
# The warning level is 0.4V higher than the specified poor level (>9.0V, <=9.5V).
# The warning level is 0.2V higher than the specified poor level (>8.5V, <=9.0V).
# The warning level is 0.1V higher than the specified poor level (<=8.5V ).
# Setting the poor level to low values is not recommended for rechargeable Batteries,
# because this increase the danger for deep discharge!!
CFLAGS += -DBAT_POOR=6400

# The sleep mode of the ATmega168 or ATmega328 is normally used by the software to save current.
# You can inhibit this with the option INHIBIT_SLEEP_MODE .
CFLAGS += -DINHIBIT_SLEEP_MODE


# Select your programmer type and port, if you wish to use avrdude.
PROGRAMMER=avrisp2
BitClock=5.0
#PROGRAMMER=avrasp
#BitClock=20.0
PORT=usb
# ********************** end of selectable options

ifeq ($(PARTNO),m8)
MCU = atmega8
HEX_FLASH_FLAGS = --change-section-lma .eeprom=0x2000
ifeq ($(OP_MHZ),1)
# BODLEV 4V, BODEN enabled, SUT 65ms, CLK 1MHz
FUSES_INT = -U lfuse:w:0x21:m -U hfuse:w:0xd9:m
# operation with 1MHz crystal!!!
FUSES_CRY = -U lfuse:w:0x3d:m -U hfuse:w:0xc9:m
FUSES_CRY_L = -U lfuse:w:0x3d:m -U hfuse:w:0xd9:m
else
# BODLEV 4V, BODEN enabled, SUT 65ms, CLK 8MHz
FUSES_INT = -U lfuse:w:0x24:m -U hfuse:w:0xd9:m
# Operation with 8MHz crystal
FUSES_CRY = -U lfuse:w:0x3f:m -U hfuse:w:0xc9:m
FUSES_CRY_L = -U lfuse:w:0x3f:m -U hfuse:w:0xd9:m
endif
endif

ifeq ($(PARTNO),m88)
MCU = atmega88
HEX_FLASH_FLAGS = --change-section-lma .eeprom=0x2000
ifeq ($(OP_MHZ),1)
# RC operation ,CLK 1MHz
FUSES_INT = -U lfuse:w:0x62:m -U hfuse:w:0xdc:m
# -U efuse:w:0xf9:m
# Operation with 8MHz crystal and /8 divider , full swing crystal
FUSES_CRY = -U lfuse:w:0x77:m -U hfuse:w:0xdc:m
# -U efuse:w:0xf9:m
# Operation with 8MHz crystal and /8 divider , low power
FUSES_CRY_L = -U lfuse:w:0x7f:m -U hfuse:w:0xdc:m
# -U efuse:w:0xf9:m
else
# RC operation ,CLK 8MHz
FUSES_INT = -U lfuse:w:0xe2:m -U hfuse:w:0xdc:m
# -U efuse:w:0xf9:m
# Operation with 8MHz crystal and /1 divider , full swing crystal
FUSES_CRY = -U lfuse:w:0xf7:m -U hfuse:w:0xdc:m
# -U efuse:w:0xf9:m
# Operation with 8MHz crystal and /1 divider , low power
FUSES_CRY_L = -U lfuse:w:0xff:m -U hfuse:w:0xdc:m
# -U efuse:w:0xf9:m
endif
endif

ifeq ($(PARTNO),m88p)
MCU = atmega88p
HEX_FLASH_FLAGS = --change-section-lma .eeprom=0x2000
ifeq ($(OP_MHZ),1)
# RC operation ,CLK 1MHz
FUSES_INT = -U lfuse:w:0x62:m -U hfuse:w:0xdc:m
# -U efuse:w:0xf9:m
# Operation with 8MHz crystal and /8 divider , full swing crystal
FUSES_CRY = -U lfuse:w:0x77:m -U hfuse:w:0xdc:m
# -U efuse:w:0xf9:m
# Operation with 8MHz crystal and /8 divider , low power
FUSES_CRY_L = -U lfuse:w:0x7f:m -U hfuse:w:0xdc:m
# -U efuse:w:0xf9:m
else
# RC operation ,CLK 8MHz
FUSES_INT = -U lfuse:w:0xe2:m -U hfuse:w:0xdc:m
# -U efuse:w:0xf9:m
# Operation with 8MHz crystal and /1 divider , full swing crystal
FUSES_CRY = -U lfuse:w:0xf7:m -U hfuse:w:0xdc:m
# -U efuse:w:0xf9:m
# Operation with 8MHz crystal and /1 divider , low power
FUSES_CRY_L = -U lfuse:w:0xff:m -U hfuse:w:0xdc:m
# -U efuse:w:0xf9:m
endif
endif

ifeq ($(PARTNO),m168)
MCU = atmega168
HEX_FLASH_FLAGS = --change-section-lma .eeprom=0x4000
ifeq ($(OP_MHZ),1)
# RC operation ,CLK 1MHz
FUSES_INT = -U lfuse:w:0x62:m -U hfuse:w:0xdc:m
# -U efuse:w:0xf9:m
# Operation with 8MHz crystal and /8 divider , full swing crystal
FUSES_CRY = -U lfuse:w:0x77:m -U hfuse:w:0xdc:m
# -U efuse:w:0xf9:m
# Operation with 8MHz crystal and /8 divider , low power
FUSES_CRY_L = -U lfuse:w:0x7f:m -U hfuse:w:0xdc:m
# -U efuse:w:0xf9:m
else
# RC operation ,CLK 8MHz
FUSES_INT = -U lfuse:w:0xe2:m -U hfuse:w:0xdc:m
# -U efuse:w:0xf9:m
# Operation with 8MHz crystal and /1 divider , full swing crystal
FUSES_CRY = -U lfuse:w:0xf7:m -U hfuse:w:0xdc:m
# -U efuse:w:0xf9:m
# Operation with 8MHz crystal and /1 divider , low power
FUSES_CRY_L = -U lfuse:w:0xff:m -U hfuse:w:0xdc:m
# -U efuse:w:0xf9:m
endif
endif

ifeq ($(PARTNO),m168p)
MCU = atmega168p
HEX_FLASH_FLAGS = --change-section-lma .eeprom=0x4000
ifeq ($(OP_MHZ),1)
# RC operation ,CLK 1MHz
FUSES_INT = -U lfuse:w:0x62:m -U hfuse:w:0xdc:m
# -U efuse:w:0xf9:m
# Operation with 8MHz crystal and /8 divider , full swing crystal
FUSES_CRY = -U lfuse:w:0x77:m -U hfuse:w:0xdc:m
# -U efuse:w:0xf9:m
# Operation with 8MHz crystal and /8 divider , low power
FUSES_CRY_L = -U lfuse:w:0x7f:m -U hfuse:w:0xdc:m
# -U efuse:w:0xf9:m
else
# RC operation ,CLK 8MHz
FUSES_INT = -U lfuse:w:0xe2:m -U hfuse:w:0xdc:m
# -U efuse:w:0xf9:m
# Operation with 8MHz crystal and /1 divider , full swing crystal
FUSES_CRY = -U lfuse:w:0xf7:m -U hfuse:w:0xdc:m
# -U efuse:w:0xf9:m
# Operation with 8MHz crystal and /1 divider , low power
FUSES_CRY_L = -U lfuse:w:0xff:m -U hfuse:w:0xdc:m
# -U efuse:w:0xf9:m
endif
endif

ifeq ($(PARTNO),m328)
MCU = atmega328
HEX_FLASH_FLAGS = --change-section-lma .eeprom=0x8000
ifeq ($(OP_MHZ),1)
# RC operation ,CLK 1MHz
FUSES_INT = -U lfuse:w:0x62:m -U hfuse:w:0xd9:m -U efuse:w:0xfc:m
# Operation with 8MHz crystal and /8 divider , full swing crystal
FUSES_CRY = -U lfuse:w:0x77:m -U hfuse:w:0xd9:m -U efuse:w:0xfc:m
# Operation with 8MHz crystal and /8 divider , low power
FUSES_CRY_L = -U lfuse:w:0x7f:m -U hfuse:w:0xd9:m -U efuse:w:0xfc:m
else
# RC operation ,CLK 8MHz
FUSES_INT = -U lfuse:w:0xe2:m -U hfuse:w:0xd9:m -U efuse:w:0xfc:m
# Operation with 8MHz crystal and /1 divider , full swing crystal
FUSES_CRY = -U lfuse:w:0xf7:m -U hfuse:w:0xd9:m -U efuse:w:0xfc:m
# Operation with 8MHz crystal and /1 divider , low power
FUSES_CRY_L = -U lfuse:w:0xff:m -U hfuse:w:0xd9:m -U efuse:w:0xfc:m
endif
endif

ifeq ($(PARTNO),m328p)
MCU = atmega328p
HEX_FLASH_FLAGS = --change-section-lma .eeprom=0x8000
ifeq ($(OP_MHZ),1)
# RC operation ,CLK 1MHz
FUSES_INT = -U lfuse:w:0x62:m -U hfuse:w:0xd9:m -U efuse:w:0xfc:m
# Operation with 8MHz crystal and /8 divider , full swing crystal
FUSES_CRY = -U lfuse:w:0x77:m -U hfuse:w:0xd9:m -U efuse:w:0xfc:m
# Operation with 8MHz crystal and /8 divider , low power
FUSES_CRY_L = -U lfuse:w:0x7f:m -U hfuse:w:0xd9:m -U efuse:w:0xfc:m
else
# RC operation ,CLK 8MHz
FUSES_INT = -U lfuse:w:0xe2:m -U hfuse:w:0xd9:m -U efuse:w:0xfc:m
# Operation with 8MHz crystal and /1 divider , full swing crystal
FUSES_CRY = -U lfuse:w:0xf7:m -U hfuse:w:0xd9:m -U efuse:w:0xfc:m
# Operation with 8MHz crystal and /1 divider , low power
FUSES_CRY_L = -U lfuse:w:0xff:m -U hfuse:w:0xd9:m -U efuse:w:0xfc:m
endif
endif

CFLAGS += -DF_CPU=$(OP_MHZ)000000UL

## Options common to compile, link and assembly rules
COMMON = -mmcu=$(MCU)

## Compile options common for all C compilation units.
CFLAGS += $(COMMON)
CFLAGS += -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d

## Assembly specific flags
ASMFLAGS = $(COMMON)
ASMFLAGS += $(CFLAGS)
ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2

## Linker flags
LDFLAGS = $(COMMON)
LDFLAGS +=  -Wl,-Map=TransistorTester.map


## Intel Hex file production flags
HEX_FLASH_FLAGS = -R .eeprom -R .fuse -R .lock -R .signature
#HEX_FLASH_FLAGS += -R .fuse -R .lock -R .signature

HEX_EEPROM_FLAGS = -j .eeprom
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings



## Objects that must be built in order to link
OBJECTS = lcd-routines.o lcd_hw_4_bit.o main.o swuart.o wait1000ms.o ReadCapacity.o ReadInductance.o ReadADC.o GetESR.o Calibrate_UR.o

## Objects explicitly added by the user
LINKONLYOBJECTS =


## Build
all: $(TARGET) TransistorTester.hex TransistorTester.eep TransistorTester.lss size

## Compile
lcd-routines.o: ../lcd-routines.c Makefile
        $(CC) $(INCLUDES) $(CFLAGS) -c  $<

lcd_hw_4_bit.o: ../lcd_hw_4_bit.S Makefile
        $(CC) $(INCLUDES) $(CFLAGS) -c  $<

ReadCapacity.o: ../ReadCapacity.c Makefile
        $(CC) $(INCLUDES) $(CFLAGS) -c  $<

ReadInductance.o: ../ReadInductance.c Makefile
        $(CC) $(INCLUDES) $(CFLAGS) -c  $<

Calibrate_UR.o: ../Calibrate_UR.c Makefile
        $(CC) $(INCLUDES) $(CFLAGS) -c  $<

ReadADC.o: ../ReadADC.S Makefile
        $(CC) $(INCLUDES) $(CFLAGS) -c  $<

GetESR.o: ../GetESR.c Makefile
        $(CC) $(INCLUDES) $(CFLAGS) -c  $<

main.o: ../main.c Makefile
        $(CC) $(INCLUDES) $(CFLAGS) -D$(UI_LANGUAGE) -c  $<

swuart.o: ../swuart.S Makefile
        $(CC) $(INCLUDES) $(CFLAGS) -c  $<

wait1000ms.o: ../wait1000ms.S Makefile
        $(CC) $(INCLUDES) $(CFLAGS) -c  $<

##Link
$(TARGET): $(OBJECTS)
         $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)

%.hex: $(TARGET)
        avr-objcopy -O ihex $(HEX_FLASH_FLAGS)  $< $@

%.eep: $(TARGET)
        -avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0

%.lss: $(TARGET)
        avr-objdump -h -S $< > $@

size: ${TARGET}
        @echo
        @echo $(OP_MHZ) MHz operation configured.
        @avr-size -C --mcu=${MCU} ${TARGET}

## Clean target
.PHONY: clean
clean:
        -rm -rf $(OBJECTS) TransistorTester.elf dep/* TransistorTester.hex TransistorTester.eep TransistorTester.lss TransistorTester.map
steril:
        make
        -rm -rf $(OBJECTS) TransistorTester.elf dep/* TransistorTester.lss TransistorTester.map


## Other dependencies
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)


# device programming
# make fuses  call if you don't have installed a crystal
fuses:
        avrdude -c $(PROGRAMMER) -B $(BitClock) -p $(PARTNO) -P $(PORT)  $(FUSES_INT)

# fuses-crytal can only used if a 8MHz Crytal is installed (between Pin 9 and 10)
fuses-crystal:
        avrdude -c $(PROGRAMMER) -B $(BitClock) -p $(PARTNO) -P $(PORT)  $(FUSES_CRY)
fuses-crystal-lp:
        avrdude -c $(PROGRAMMER) -B $(BitClock) -p $(PARTNO) -P $(PORT)  $(FUSES_CRY_L)

# make upload  additionally calls make to compile the software for selected target
upload:
        make
        avrdude -c $(PROGRAMMER) -B $(BitClock) -p $(PARTNO) -P $(PORT) -U flash:w:./TransistorTester.hex:a \
        -U eeprom:w:./TransistorTester.eep:a
program:
        make
        avrdude -c $(PROGRAMMER) -B $(BitClock) -p $(PARTNO) -P $(PORT) -U flash:w:./TransistorTester.hex:a \
        -U eeprom:w:./TransistorTester.eep:a
eeprom:
        avrdude -c $(PROGRAMMER) -B $(BitClock) -p $(PARTNO) -P $(PORT) \
        -U eeprom:w:./TransistorTester.eep:a
verify:
        avrdude -D -c $(PROGRAMMER) -B $(BitClock) -p $(PARTNO) -P $(PORT) -U flash:v:./TransistorTester.hex:a \
        -U eeprom:v:./TransistorTester.eep:a -v
upload_orig:
        avrdude -c $(PROGRAMMER) -B $(BitClock) -p $(PARTNO) -P $(PORT) -U flash:w:./TransistorTestorig.hex:a \
        -U eeprom:w:./TransistorTestorig.eep:a


本版积分规则

QQ|一淘宝店|手机版|商店|电子DIY套件|一乐电子 ( 粤ICP备09076165号 ) 公安备案粤公网安备 44522102000183号

GMT+8, 2024-6-14 22:48 , Processed in 0.055322 second(s), 32 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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