瑞安万鑫电子
日历
网志分类
· 所有网志 (16)
· 电子技术 (1)
· C51 (1)
· AVR (4)
· ARM (0)
· CPLD/FPGA/NIOS (1)
· 嵌入式系统 (1)
· DSP (3)
· 闲谈水池[专门灌水] (1)
· Delphi (4)
最新的评论
站内搜索
友情链接
· 歪酷博客
· 我的歪酷 非非共享界
· 电子电脑

订阅 RSS

0003304

歪酷博客

瑞安万鑫电子


万鑫 @ 2006-07-15 20:44

(引)恰当的PCB板设计是射频/微波电路设计的重要部分。在高频输入和输出引脚端使用控制阻抗的导线和使导线尽可能的短,以减少损耗和辐射。在高频,导线长度为λ/lO或者更长,其作用类似天线。保持导线尽可能地短,可以减少寄生电感。一般情况,2.54 cm(1英寸)的PCB导线长度,大约附加20 nH的寄生电感。寄生电感将影响实际的元件参数。例如:1.27 cm(O.5英寸)长的导线与一个100 nH的电感器连接,将增加额外的10 nH电感。使用宽的导线、可靠的接地或者电源板在信号导线的下面可以减少寄生电感。另外,所有的GND引脚端要求使用低电感连接到地,尽可能地靠近所有的VDD引脚端,连接退耦电容到地。


 
万鑫 @ 2006-06-01 20:44

/*****************************************************
This program was produced by the
CodeWizardAVR V1.24.8c Professional
Automatic Program Generator
?Copyright 1998-2006 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com

Project : M8
Version : 1.0
Date    : 2006-5-5
Author  : WCJ                           
Company : 瑞安万鑫电子                           
Comments:AVR(ATMEGA8) 入门学习板


Chip type           : ATmega8L
Program type        : Application
Clock frequency     : 4.000000 MHz
Memory model        : Small
External SRAM size  : 0
Data Stack size     : 256
*****************************************************/
//               本章简介
/****************************************************
一,学习目的:LED数码管动态显示

二,基础知识:
        AVR采用3个8位寄存器控制I/O端口
        方向寄存器:DDRx     (可读写)
        数据寄存器:PORTx    (可读写)
        输入引脚寄存器:PINx (只读)
        * SFIOR寄存器中的上拉屏蔽位PUD为"1",则会屏蔽掉所有端口引脚中的内部上拉电阻  
        数码管的驱动动态显示
三,实验任务:  
        1.编写74HC164的驱动程序
        2.在4位共阳数码管上动态显示数字
四,注意事项:
       
        将JP1上的PC2,PC3,PC4,PC5跳针短路(数码管的位选)
        将JP2上的PB3,PB5跳针短路(通过74HC164实现段码)
****************************************************/
#include <mega8.h>//包含ATMEGA8L的寄存器定义,和中断向量表
#include <delay.h>//CVAVR 自带的延时函数
//数码管的段码,低电平有效
#define  DATA_164 PORTB.3//164数据脚
#define  CLK_164  PORTB.5//164时钟脚
//数码管的位码,低电平有效
#define BIT4 PORTC.5//千位     
#define BIT3 PORTC.4//百位
#define BIT2 PORTC.3//十位
#define BIT1 PORTC.2//个位
//                BIT 7 6 5 4 3 2 1 0
/*            LED段码:低电平亮   段码
数字 74HC164D输出码位:G C H D B F A E
0:                    1 0 1 0 0 0 0 0              0xA0
1:                    1 0 1 1 0 1 1 1              0xB7
2:                    0 1 1 0 0 1 0 0              0x64
3:                    0 0 1 0 0 1 0 1              0x25
4:                    0 0 1 1 0 0 1 1              0x33
5:                    0 0 1 0 1 0 0 1              0x29
6:                    0 0 1 0 1 0 0 0              0x28
7:                    1 0 1 1 0 1 0 1              0xB5
8:                    0 0 1 0 0 0 0 0              0x20
9:                    0 0 1 0 0 0 0 1              0x21
.:                    1 1 0 1 1 1 1 1              0xDF
*/                        /* 0   1    2    3    4    5    6    7    8    9    .*/
unsigned char LEDcode[11]={0xA0,0xB7,0x64,0x25,0x33,0x29,0x28,0xB5,0x20,0x21,0xDF};         
unsigned char display_buf[4];//显示缓冲寄存器
//写164串行接口
//数码管的段码
void wr_164(unsigned char wr_data)
{
        unsigned char i;
        for(i=0;i<8;i++)
        {
                if((wr_data&0x80)==0x80)
                {DATA_164=1;} 
                else
                {DATA_164=0;} 
                CLK_164=0;
                CLK_164=1;   
                wr_data<<=1;
        }  
}
  

void display(void)
{       //送段码,显示;延时,关闭显示
        wr_164(display_buf[0]);BIT1=0;delay_ms(2);BIT1=1;
        wr_164(display_buf[1]);BIT2=0;delay_ms(2);BIT2=1;
        wr_164(display_buf[2]);BIT3=0;delay_ms(2);BIT3=1;
        wr_164(display_buf[3]);BIT4=0;delay_ms(2);BIT4=1;
}
// Declare your global variables here    
//4位数最高为9999 所以选INT类型,这里没有考虑负数 
void numbertobcd(unsigned int number)
{       unsigned int i;
        i=number/1000;
        display_buf[0]=LEDcode[i];
        number=number%1000;
        i=number/100;
        display_buf[1]=LEDcode[i];
        number=number%100;
        i=number/10;
        display_buf[2]=LEDcode[i];
        i=number%10;
        display_buf[3]=LEDcode[i]; 
        display();//显示数据   number
}
void main(void)
{
// Declare your local variables here
unsigned int temp=1234;//预显示的数值
// Input/Output Ports initialization
// Port B initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTB=0xff;
DDRB=0xEF;

// Port C initialization
// Func6=In Func5=Out Func4=Out Func3=Out Func2=Out Func1=In Func0=In
// State6=T State5=0 State4=0 State3=0 State2=0 State1=T State0=T
PORTC=0x00;//
DDRC=0xFF;//数码管位选

// Port D initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0x00;
DDRD=0x00;
PORTD.3=1;//输入上拉;
DDRD.3=0;//PORTD.3为输入方式;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
TCCR0=0x00;
TCNT0=0x00;

// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer 1 Stopped
// Mode: Normal top=FFFFh
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer 1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;

// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer 2 Stopped
// Mode: Normal top=FFh
// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;

// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
MCUCR=0x00;

// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;

// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;

while (1)
      {
   
      numbertobcd(temp); //数码管显示1234 TEMP的值
     
      };
}



 
万鑫 @ 2006-05-23 21:29

/*****************************************************
This program was produced by the
CodeWizardAVR V1.24.8c Professional
Automatic Program Generator
?Copyright 1998-2006 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com

Project : M8
Version : 1.0
Date    : 2006-5-5
Author  : WCJ                           
Company : 瑞安万鑫电子                           
Comments:AVR(ATMEGA8) 入门学习板


Chip type           : ATmega8L
Program type        : Application
Clock frequency     : 4.000000 MHz
Memory model        : Small
External SRAM size  : 0
Data Stack size     : 256
*****************************************************/
//               本章简介
/****************************************************
一,学习目的:AVR的IO口读写操作  

二,基础知识:AVR采用3个8位寄存器控制I/O端口
        方向寄存器:DDRx     (可读写)
        数据寄存器:PORTx    (可读写)
        输入引脚寄存器:PINx (只读)
        * SFIOR寄存器中的上拉屏蔽位PUD为"1",则会屏蔽掉所有端口引脚中的内部上拉电阻  

三,实验任务:
        1:PD3读取PC串口第4脚,使接在PB1脚上LED(D2 0C1A) (低电平亮,高电平暗)
       
四,注意事项:
        PC串口是RS232电平,所以通过板子上的MAX232进行电平转换
        将JP2上的PB1跳针短路,将PORTB.1连接到D2的阴极
        将JP3上的PD3跳针短路,PD3读取串口RTS脚(4)电平,通过程序控制D2
****************************************************/
#include <mega8.h>//包含ATMEGA8L的寄存器定义,和中断向量表
#include <delay.h>//CVAVR 自带的延时函数
void main(void)
{

PORTB=0x02;//输出为1;
DDRB=0x02;//PORTB.1为输出方式;
/*
或者
PORTB=0b00000010;//输出为1;
DDRB=0b00000010;//PORTB.1为输出方式;
*/ 
/*
或者
PORTB.1=1;//输出为1;
DDRB.1=1;//PORTB.1为输出方式;
*/
PORTD.3=1;//输入上拉;
DDRD.3=0;//PORTD.3为输入方式;
while (1)
      {
      if(PIND.3==0)//读取管脚状态
      {
        PORTB.1=0;//D2亮
        delay_ms(200);
        PORTB.1=1;//D2暗
        delay_ms(200);
      }
      else
      {
        PORTB.1=1;//D2暗
      };
      }
}