搜索
bottom↓
回复: 2

[恢复]-使用AVR做USB转RS232C和USB转通用IO即 AVR-CDC & AVR-IO 全部资料,而且我

[复制链接]

出0入0汤圆

发表于 2009-2-16 18:01:51 | 显示全部楼层 |阅读模式
使用AVR做USB转RS232C和USB转通用IO即 AVR-CDC & AVR-IO 全部资料,而且我还把它 翻译 了的哟!!!!!!!!!            回复数:48,点击数:2702
【楼主位】 kevinzcp

积分:152
派别:
等级:------
来自:深圳
        原文出处:http://www.recursion.jp/avrcdc/

中英对比请看一楼

AVR - CDC


(原文件名:1.JPG)


cdctiny45rc

AVR-CDC is a USB-RS232C interface using the CDC (Communication Device Class) protocol. Although the bulk endpoint required for CDC is not allowed within the low-speed USB standard, it works fine on major platforms.

1. No dedicated driver necessary. OS  loads a built-in driver ("usbser.sys" on Windows)
2. Very low cost. With ATtiny45/2313, this is the cheapest solution for the USB-RS232C interface.
On Windows, an INF file is required to load the pre-installed driver when the device is connected for the first time. The virtual COM port appears after the connection established. No special procedure is required to Macintosh OS X.


(原文件名:2.gif)



Figure 1:  AVR-CDC circuit for ATtiny45(tiny45制作AVR-CDC的电路图)

The Vcc should be lower than 3.6V to meet the USB standard. Use a quartz crystal instead of a ceramic resonator for stable connection. The internal RC oscillator can substitute the external crystal to simplify hardware (cdctiny45rc). Program size is about 3KB on AVR. Since ATtiny45 has no USART, 4800bps may be the practical speed. ATmega8/48/88 can achieve the higher transfer rate (e.g. 38400bps) using the internal USART.


(原文件名:3.jpg)

Figure 2:  Tiny USB interface (cdctiny45)

I implemented this to add a USB interface to an ATmega88 system. The system is for educational purpose and has a tiny PostScript-like compiler inside. The power consumption of ATtiny45 is about 8mA (24mW).

The AVR-CDC is based on Object Development's AVR-USB. The portion of code that I added is published as free software (GPL2). See the License.txt together with the Object Development's license agreement.

Download INF files here for Windows PC. AVR-CDC is Windows Vista ready.

avrcdc_.inf.zip                               (26KB)

This code is for ATtiny45/ATmega8/48/88.

AVR-CDC.2008-08-25.tgz            (222KB)
AVR-CDC.2008-08-25.zip            (266KB)

AVR-CDC.2008-01-27.tgz            (129KB)
AVR-CDC.2008-01-27.zip            (191KB)



CDC - 2313

This is the subset of AVR-CDC for ATtiny2313. It provides the 9600bps 8N1 settings only. Improve it by yourself.

CDC-2313.2008-08-25.tgz            (110KB)
CDC-2313.2008-08-25.zip            (137KB)

CDC-2313.2008-01-27.tgz             (90KB)
CDC-2313.2008-01-27.zip            (117KB)

CDC - IO

This is another example of AVR-CDC. CDC-IO provides the 18-bit parallel port interface using AVR microcontroller (ATmega8/48/88).
You can control port bits by sending simple text commands via terminal software or from your own program.
The ATtiny45/461 versions are available. They use the internal RC oscillator.


(原文件名:4.gif)




Figure 3:  CDC-IO circuit for ATmega8/48/88

CDC-IO command


address: memory mapped I/O address in hexadecimal
data: 8 bit data in hexadecimal
delimiter: Tab, Space, CR, LF
predefined address: (case-insensitive)
    PINB, DDRB, PORTB PINC, DDRC, PORTC PIND, DDRD, PORTD
example: ('_' means delimiter)
    DDRB_?_            Replies DDRB value with CR-LF.
    12_34_=_            Writes 0x12 to address: 0x34, replies CR-LF.
    FB_PORTC_&_    Writes (PORTC & 0xFB) to PORTC, replies CR-LF.

Previous data and address can be reused. Just enter command character to repeat.

Use "Set Double" command to write on EEPROM.

USB line is connected to PORTD2,3. Avoid changing these bits. Modify other DDRD bits using '&', '|' or '^'.
If PORTD is assigned to output, use PIND to toggle bits.

USB bus-powered Vcc is about 3.6V. Be careful of interfacing to the higher voltage circuit. Usable bus-powered current is about 80mA.

** Any SFRs (special function registers) are accessible. See AVR datasheet to use Timers, ADC, USART, etc.


(原文件名:5.jpg)


Figure 4:  CDC-IO on ATmega48

CDC-IO.2008-08-25.tgz             (182KB)
CDC-IO.2008-08-25.zip             (218KB)

CDC-IO.2007-07-07.tgz             (79KB)
CDC-IO.2007-07-07.zip            (106KB)



With the 20MHz clock, it sometimes mistakes the signal timing of EOP for Reset. Compile with the lower optimization level (e.g. -O1,s), or modify usbdrv.c : usbPoll() as below.
    --     for(i = 10; i > 0; i--){
    ++     for(i = 20; i > 0; i--){

AVR-CDC  is an experimental project. If your application needs stable technologies, consider using FTDI's FT232 / FT245 instead



点击此处下载 ourdev_484161.zip(文件大小:265K) (原文件名:AVR-CDC.2008-08-25.zip)
点击此处下载 ourdev_484162.zip(文件大小:26K) (原文件名:avrcdc_inf.zip)
点击此处下载 ourdev_484163.zip(文件大小:136K) (原文件名:CDC-2313.2008-08-25.zip)
点击此处下载 ourdev_484164.zip(文件大小:217K) (原文件名:CDC-IO.2008-08-25.zip)





本贴被 kevinzcp 编辑过,最后修改时间:2008-11-05,10:33:16.
__________________________
43858221@qq.com大家交流就会进步的
2008-11-05,09:59:41        
资料 邮件         编辑 删除
【1楼】 kevinzcp

积分:152
派别:
等级:------
来自:深圳
        翻译后的

原文出处:http://www.recursion.jp/avrcdc/

英文水平太差了,不准确或错误的地方请包涵

AVR - CDC



(原文件名:1.JPG)

cdctiny45rc

AVR-CDC is a USB-RS232C interface using the CDC (Communication Device Class) protocol. Although the bulk endpoint required for CDC is not allowed within the low-speed USB standard, it works fine on major platforms.
(AVR-CDC 是一个使用通讯装置类协议的USB转RS232C的接口,尽管它的大小等不允许集成到标准的低速USB设备中,但它工作却是很正常的)

1. No dedicated driver necessary. OS  loads a built-in driver ("usbser.sys" on Windows)
(不需要专用的驱动程序 ,WINDOWS操作系统会载入内置的驱动"usbser.sys").
2. Very low cost. With ATtiny45/2313, this is the cheapest solution for the USB-RS232C interface.
(超低成本,使用了最便宜的tiny45/2313芯片来制作这个USB-RS232C接口)
On Windows, an INF file is required to load the pre-installed driver when the device is connected for the first time. The virtual COM port appears after the connection established. No special procedure is required to Macintosh OS X.
(在WINDOWS平台上,当装置被连接后需要预安装一个INF文件的驱动,联接稳定后将会出现一个虚拟的串口,苹果操作系统OS X上不需指定程序或驱动)


(原文件名:2.gif)

Figure 1:  AVR-CDC circuit for ATtiny45(tiny45制作AVR-CDC的电路图)

The Vcc should be lower than 3.6V to meet the USB standard. Use a quartz crystal instead of a ceramic resonator for stable connection. The internal RC oscillator can substitute the external crystal to simplify hardware (cdctiny45rc). Program size is about 3KB on AVR. Since ATtiny45 has no USART, 4800bps may be the practical speed. ATmega8/48/88 can achieve the higher transfer rate (e.g. 38400bps) using the internal USART.
(装置的电源电压须小于3.6V来配合USB的标准,为了装置的稳定使用石英晶振来代替陶瓷震荡器,如果为了简化线路也可使用芯片内部的RC振荡器,程序大小在3KB左右,因为Tiiny45没有USART所以波特率只到4800,M8/48/88有使用内部的USART所以能达到高达 38400的波特率)



(原文件名:3.jpg)


Figure 2:  Tiny USB interface (cdctiny45)

I implemented this to add a USB interface to an ATmega88 system. The system is for educational purpose and has a tiny PostScript-like compiler inside. The power consumption of ATtiny45 is about 8mA (24mW).
(我使用M8做了一个,它可以当做是一个样品,?,TINY45做的功耗只有8MA,约24mW)

The AVR-CDC is based on Object Development's AVR-USB. The portion of code that I added is published as free software (GPL2). See the License.txt together with the Object Development's license agreement.
(AVR-CDC是在Object Development's 的AVR-USB基础上开发的,因此我增加一部份代码并免费的进行发布,可以看许可)

Download INF files here for Windows PC. AVR-CDC is Windows Vista ready.
(下载AVR-CDC 在使用WINDOWS下的INF文件它同样支持VISTA)
avrcdc_.inf.zip                               (26KB)

This code is for ATtiny45/ATmega8/48/88.
(Tiny/M8/M48/M88源代码下载)
AVR-CDC.2008-08-25.tgz            (222KB)
AVR-CDC.2008-08-25.zip            (266KB)

AVR-CDC.2008-01-27.tgz            (129KB)
AVR-CDC.2008-01-27.zip            (191KB)



CDC - 2313

This is the subset of AVR-CDC for ATtiny2313. It provides the 9600bps 8N1 settings only. Improve it by yourself.
(这是使用TINY2313开发的AVR-CDC 它只提供了9600的波特率及8个数据位1个其它位的设置通讯方法,你可以自己改进)

CDC-2313.2008-08-25.tgz            (110KB)
CDC-2313.2008-08-25.zip            (137KB)

CDC-2313.2008-01-27.tgz             (90KB)
CDC-2313.2008-01-27.zip            (117KB)

CDC - IO

This is another example of AVR-CDC. CDC-IO provides the 18-bit parallel port interface using AVR microcontroller (ATmega8/48/88).
(这是AVR-CDC其它的一个样版,CDC-IO它使用M8/M48/M48并提供了18位并行口的接口)
You can control port bits by sending simple text commands via terminal software or from your own program.
(你可以使用一些简单的字符命令通过软件接口,能控制这些端口)
The ATtiny45/461 versions are available. They use the internal RC oscillator.
(tiny45/461版它使用了内部的RC振荡器)


(原文件名:4.gif)


Figure 3:  CDC-IO circuit for ATmega8/48/88

CDC-IO command


address: memory mapped I/O address in hexadecimal
data: 8 bit data in hexadecimal
delimiter: Tab, Space, CR, LF
predefined address: (case-insensitive)
    PINB, DDRB, PORTB PINC, DDRC, PORTC PIND, DDRD, PORTD
(地址:内存映射I/O使用16进制
数据:8位16进制
分隔位:TAB,SPACE,CR,LF
predefined address: (case-insensitive)
)
example: ('_' means delimiter)
    DDRB_?_            Replies DDRB value with CR-LF.
    12_34_=_            Writes 0x12 to address: 0x34, replies CR-LF.
    FB_PORTC_&_    Writes (PORTC & 0xFB) to PORTC, replies CR-LF.

Previous data and address can be reused. Just enter command character to repeat.

Use "Set Double" command to write on EEPROM.

USB line is connected to PORTD2,3. Avoid changing these bits. Modify other DDRD bits using '&', '|' or '^'.
If PORTD is assigned to output, use PIND to toggle bits.

USB bus-powered Vcc is about 3.6V. Be careful of interfacing to the higher voltage circuit. Usable bus-powered current is about 80mA.

** Any SFRs (special function registers) are accessible. See AVR datasheet to use Timers, ADC, USART, etc.


(原文件名:5.jpg)


Figure 4:  CDC-IO on ATmega48

CDC-IO.2008-08-25.tgz             (182KB)
CDC-IO.2008-08-25.zip             (218KB)

CDC-IO.2007-07-07.tgz             (79KB)
CDC-IO.2007-07-07.zip            (106KB)



With the 20MHz clock, it sometimes mistakes the signal timing of EOP for Reset. Compile with the lower optimization level (e.g. -O1,s), or modify usbdrv.c : usbPoll() as below.
    --     for(i = 10; i > 0; i--){
    ++     for(i = 20; i > 0; i--){

AVR-CDC  is an experimental project. If your application needs stable technologies, consider using FTDI's FT232 / FT245 instead


本贴被 kevinzcp 编辑过,最后修改时间:2008-11-05,10:02:40.
__________________________
43858221@qq.com大家交流就会进步的
2008-11-05,10:00:14        
资料 邮件         编辑 删除
【2楼】 wajlh
积分:535
派别:
等级:------
来自:山东-莱阳-在德州上学
        楼主辛苦了
__________________________
喜欢这里的气氛
2008-11-05,13:24:39        
资料 邮件         编辑 删除
【3楼】 lin28
积分:520
派别:
等级:------
来自:
        有IAR AVR下开发的例子吗
 
2008-11-05,14:14:00        
资料 邮件         编辑 删除
【4楼】 kanhai2222

积分:100
派别:
等级:------
来自:广东
        谢谢了!
__________________________
把所有能量聚焦于一点,无坚不摧;把所有精力聚焦于一点,无所不能!
2008-11-05,16:52:45        
资料 邮件         编辑 删除
【5楼】 Totry

积分:74
派别:
等级:------
来自:NJ.JiangSu
        mark!
 
2008-11-05,18:04:02        
资料 邮件         编辑 删除
【6楼】 68336016

积分:847
派别:
等级:------
来自:
        在USBasp上用这个固件变成USB TO TTL,偶尔给STC下载程序倒是挺方便的
__________________________
http://shop35447293.taobao.com/
usbasp、stk500、usb-blaster
2008-11-05,19:38:51        
资料 邮件         编辑 删除
【7楼】 china_china

积分:791
派别:
等级:------
来自:china
        楼主辛苦了,不顶不行:)
__________________________
世界上总共有10种人,一种懂得什么是二进制,一种不懂。
2008-11-05,20:20:33        
资料 邮件         编辑 删除
【8楼】 nbanba
积分:8
派别:
等级:------
来自:
        谢谢楼主
 
2008-11-05,20:25:51        
资料 邮件         编辑 删除
【9楼】 czzhouyun
积分:290
派别:
等级:------
来自:江苏常州
        mark
__________________________
czzhouyun@hotmail.com
http://shop34549393.taobao.com/
www.flymcu.com
2008-11-05,20:28:28        
资料 邮件         编辑 删除
【10楼】 cxq200300 小强

积分:83
派别:
等级:------
来自:南京理工
        不错…
__________________________
-。-!
2008-11-05,23:50:58        
资料 邮件         编辑 删除
【11楼】 zxqwork

积分:325
派别:
等级:------
来自:郑州-龙岩-厦门
        先记录下,回头好好学
 
2008-11-06,00:16:55        
资料 邮件         编辑 删除
【12楼】 ba1731

积分:663
派别:
等级:------
来自:北京
        mark,顶了。。。。
 
2008-11-06,01:44:46        
资料 邮件         编辑 删除
【13楼】 wnju
积分:18
派别:
等级:------
来自:
        先顶一下!
 
2008-11-06,13:30:13        
资料 邮件         编辑 删除
【14楼】 yaya001
积分:658
派别:
等级:------
来自:
        mark
 
2008-11-06,16:04:42        
资料 邮件         编辑 删除
【15楼】 xintrone
积分:21
派别:
等级:------
来自:
        mark
 
2008-11-06,19:17:52        
资料 邮件         编辑 删除
【16楼】 zhao_123456
积分:299
派别:
等级:------
来自:成都
        记号!
 
2008-11-06,20:12:44        
资料 邮件         编辑 删除
【17楼】 wxws
积分:503
派别:
等级:------
来自:江苏江阴
        这个这个....
是不是早研究过了呀
看下USBASP,一个道理....

还有,USB接口肯定不稳定,前年就试过.
搜一下USBASP,然后加两个稳压管.
__________________________
Arduino 专项
http://wxws.imlab.cn
2008-11-07,02:34:04        
资料 邮件         编辑 删除
【18楼】 armok 阿莫

积分:43560
派别:
等级:------
来自:ourdev.cn 站长
        COOL !
__________________________
There's something good in this world. And it's worth fighting for ……
我的手机:13925800119 。如果本网站不正常,请用手机短信通知我。
这里是没有广告的纯技术网站,也不会回答邮购部的问题。邮购问题请到 http://www.mailshop.cn/bbs 上提问。谢谢支持。
2008-11-07,03:08:46        
资料 邮件         编辑 删除
【19楼】 zhuzi1441
积分:501
派别:
等级:------
来自:
        mark,thank you
 
2008-11-07,03:27:55        
资料 邮件         编辑 删除
【20楼】 wxfhw
积分:689
派别:
等级:------
来自:
        【6楼】 68336016 :“在USBasp上用这个固件变成USB TO TTL,偶尔给STC下载程序倒是挺方便的”
  请教:我做的“USB TO TTL”,其他的测试都正常;但是,和“STC下载程序”配合,老是不行——连接半天,结果提示错误!
  您都是正常的吗?“STC下载程序”是什么版本?

  说明:我使用M8的USBasp,实现了USB TO TTL;使用楼主的 AVR=CDC(M8),亦实现了USB TO TTL。
 
2008-11-07,07:24:26        
资料 邮件         编辑 删除
【21楼】 jun427
积分:57
派别:
等级:------
来自:
        好资料,
 
2008-11-07,07:31:28        
资料 邮件         编辑 删除
【22楼】 lljyes
积分:294
派别:
等级:------
来自:
        做个记号!
 
2008-11-07,14:05:02        
资料 邮件         编辑 删除
【23楼】 kevinzcp

积分:152
派别:
等级:------
来自:深圳
        回 【20楼】 wxfhw
给STC下载程序时有时会遇到这种问题,用TTL电平的RXD 与TXD 直接与MCU的RXD与TXD相连时,RXD与TXD上的电压会串到目标板上,让MCU不能彻底断电,我用的方法是通电的同时再插上RXD与TXD线的插头!!哈哈!
__________________________
43858221@qq.com大家交流就会进步的
2008-11-07,17:26:59        
资料 邮件         编辑 删除
【24楼】 68336016

积分:847
派别:
等级:------
来自:
        20 楼
我就是用公版的USBASP电路,STC下载软件是stc-isp-v3.91-not-setup,试过几次,暂时没出现错误,两者都是USB口取的电。

一般不会忘记,不过还是要问下你下载时有没有给STC芯片断电上电?因为我刚才特地又试验很多次,也没出错

我量了下,TXD偷过去的电压只有1V多,在我这里没什么影响

本贴被 68336016 编辑过,最后修改时间:2008-11-07,18:54:30.
__________________________
http://shop35447293.taobao.com/
usbasp、stk500、usb-blaster
2008-11-07,18:38:30        
资料 邮件         编辑 删除
【25楼】 kevinzcp

积分:152
派别:
等级:------
来自:深圳
        要断电呀,不然怎么能下载呢,
如果出现了不能下载的情况就可以试试我说的两都同时插上电路板上去!!!

同时也感谢阿莫的COOL~~~~~^_^!
__________________________
43858221@qq.com大家交流就会进步的
2008-11-07,19:09:00        
资料 邮件         编辑 删除
【26楼】 wxfhw
积分:689
派别:
等级:------
来自:
        回答楼上两位朋友:
    1、我的确特地“增加”了,STC芯片的断电开关。
    2、谢谢 68336016 :特地重复进行了试验。
    3、kevinzcp 说的:通电的“同时”、“再插上”RXD与TXD线的插头——能否详细描绘一下——看来。为了验证是不是因为“RXD与TXD上的电压会串到目标板上,让MCU不能彻底断电”的问题,恐怕要加一个“多路继电器控制开关”了?
 
2008-11-07,21:05:36        
资料 邮件         编辑 删除
【28楼】 kevinzcp

积分:152
派别:
等级:------
来自:深圳
        就是左手在给MCU所在的目标板通电瞬间右手就插上下载线的插头!

本贴被 kevinzcp 编辑过,最后修改时间:2008-11-07,21:20:16.
__________________________
43858221@qq.com大家交流就会进步的
2008-11-07,21:18:44        
资料 邮件         编辑 删除
【29楼】 wxfhw
积分:689
派别:
等级:------
来自:
        【28楼】 kevinzcp :就是左手在给MCU所在的目标板通电瞬间右手就插上下载线的插头!

  谢谢!和我想加一个“同步控制继电器”的理解差不多......
 
2008-11-08,08:11:40        
资料 邮件         编辑 删除
【30楼】 gerbee

积分:853
派别:
等级:------
来自:怕老婆党
         mark  
__________________________
辛辛苦苦一年都变成印花税了 >_<
2008-11-09,12:58:50        
资料 邮件         编辑 删除
【31楼】 wp007
积分:9
派别:
等级:------
来自:
        谢谢楼主的分享

阿莫论坛20周年了!感谢大家的支持与爱护!!

如果想吃一顿饺子,就得从冰箱里取出肉,剁馅儿,倒面粉、揉面、醒面,擀成皮儿,下锅……
一整个繁琐流程,就是为了出锅时那一嘴滚烫流油的热饺子。

如果这个过程,禁不住饿,零食下肚了,饺子出锅时也就不香了……《非诚勿扰3》
头像被屏蔽

出0入0汤圆

发表于 2009-2-28 03:41:08 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽

出0入0汤圆

发表于 2021-2-10 17:54:51 | 显示全部楼层
感谢分享
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-3-28 19:47

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

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