마이크로 프로세서 Term 과제(AVR 제어)전자공학부contents1. 동작내용 32. 코드 53. 해석 204. Discussion 22연결 후 리셋버턴을 실행시킨 모습LED 동작 :타이머 인터럽트에 의해서 LED가 깜빡거린다.시계동작 :타이머 인터럽트를 1/244초 마다 오버플로우가 발생하도록 하여 시간을 맞추고, 세그먼트를 이용해서 해당 값을 표시한다. 외부 인터럽트를 이용해서 시간 값을 새로 초기화 하거나 동작을 끝낼 수 있다.1. 동작 내용리모컨 동작 :타이머 인터럽트와 IR 센서가 연결된 외부 인터럽트를 이용해서 값을 알아내고 분석하여 데이터로 만들어 해당 입력 버턴을 알아낸다.;***************************************************************************;* Simple Test program for ATmega 128;*;* Number :AVR900;* File Name :"AVR128asm5_2.asm";* Title : UART Test Routine #2;* Date : 12.11.03;* Version :1.0;* Target MCU :ATmega128;*;* DESCRIPTION;*;* This program is for simple testing of UART Trensmission/Reception;***************************************************************************.include "m128def.inc";***** Definitions.equ TAP = $09.equ LF = $0A.equ CR = $0D.equ EOS= $00.def temp = r16.def temp2 = r17;.def timecnt = r18 ;count 244 to make 1sec.def flag = r19 ; LED input/ouput, segment / remotecon IR_reciever.def segen= r20.deftd, temp;ldi temp, LOW($2A); INT) & INT1 & INT2 On, Mode = Falling EdgestsEICRA, temp;lditemp, LOW(0);outEICRB, temp ;lditemp, LOW(7);outEIMSK, temp;outEIFR, temp;ret ;;***********************************************;EINT2_init;***********************************************EINT2_init :pushtemp ;IR sensor is External Interrupt2lditemp, $04;outPORTD, temp;PORTD [2]bit is connected External Interrupt2 //ldi temp, $20 ;EICRA [5],[4]bit is Interrupt Sense Control bitssts EICRA, temp;if ISC2 is "10", then Falling edge of INT2 generates asynchronously an interrupt requestlditemp, $04;if EIMSK [2]bit is '1', then INT2 will be enabledoutEIMSK, temp;poptemp;ret ;;****************************** intrupt operation***************************;****************************************************************************;* Timer/Counter 0 : for LED, CLOCK SEGMENT;****************************************************************************Timer0_OVF :cli ;pushr0incsegcntlslsegencpisegen, $10brneSkip_Res*****PrintCmdCursor:CALL NewLine ;ldi ZH, HIGH(2*CmdCursor) ; Since program memory is 16 bit (2 byte)ldi ZL, LOW(2*CmdCursor) ; we have to multiply 2 at the starting indexrcall PutStringP ;RET ;;****************************************************************************;* Read Command Routine;* Set Y register to point the start of buffer in Data Memory;****************************************************************************ReadCmd:ldi YH, HIGH(buffer) ; Set Y register to the start address of bufferldi YL, Low(buffer) ;rcall GetString ;ret;****************************************************************************;* Command Interprete;* Set X register to point the start of buffer in Data Memory;****************************************************************************CmdInterprete:ldi XH, High(buffer) ; Set X register be the start address of bufferldi XL, Low(buffer) ;ld temp, X+ ; Get one character and store in tempcpi temp, '1' ; Check if it is first command numberbreq Cmd_LEDt store EOSret;***********************************************;F_ITOA;***********************************************F_ITOA :pushtempITOA_HIGH :movtemp, temp2anditemp, $F0lsrtemplsrtemplsrtemplsrtemprcallF_CONVERTstx+, tempITOA_LOW :movtemp, temp2anditemp, $0FrcallF_CONVERTstx+, tempITOA_END :poptempret;***********************************************;F_CONVERT;***********************************************F_CONVERT :cpitemp, $0AbrgeCONVERT_2CONVERT_1 :subitemp, -$30rjmpCONVERT_ENDCONVERT_2 :subitemp, -$37 ;($37 = 55)CONVERT_END :retPutStringData :ldr0, x+tstr0breqPutStringData_endcallputcharrjmpPutStringDataPutStringData_end :ret;;***********************************************;LEADER_START:;; detect '0', '1' with stored data;***********************************************LEADER_START:ld temp, y+LEADER:ld temp, y+cpi temp, 100brge morethan100 ;if more than 100jmp R_forevermorethan100:cpi temp, 110brlt LEADER_END ;if less than 110 -> leader_endjmp R_foreverLEADER_END:ldi last_cnt, 32DAte_buf_empty_end :poptemp;poptemp;ret;;***********************************************;buf_empty - make remote_buffer empty;***********************************************buf_empty :pushtemp;pushtemp;ldixl, low(copy_buffer)ldixh, high(copy_buffer)lditemp, 80lditemp, 0buf_empty_loop :breqbuf_empty_end;if temp is 0, then rjmpendstx+, temp; store '0' at my_bufferdectemprjmpbuf_empty_loopbuf_empty_end :poptemp;poptemp;ret;Cmd_Wrong:;/* Error Message Printing Routine */CALL NewLine ;ldi ZH, HIGH(2*badcmd) ; Since program memory is 16 bit (2 byte)ldi ZL, LOW(2*badcmd) ; we have to multiply 2 at the starting indexrcall PutStringP ;rjmp Cmd_Done;;****************************************************************************;* Constant Data;****************************************************************************segdata:.db$03, $9f, $25, $0d, $99, $49, $41, $1f, $01, $09Title:.db TAP,"+-------------------------------------------+",CR,LF ;.db TAP,"| This is a AVR Test Board |",CR,LF ;.db TAP,"|.
각각 PSK와 FSK 시스템을 시뮬레이션 하기위해 시뮬링크를 이용하였다. 랜덤 비트를 생성 후 FSK, PSK 모듈레이터를 통과한 후 가우시안 채널을 통과한 후 다시 디모듈레이트 후 에러 확률을 계산하여 시스템의 BER을 측정해 본다.<중 략>위 그래프에서는 시스템의 EbNo에 따른 BER 값만 알 수 있다. 그래프가 안쪽에 있을수록 같은 error free가 EbNo가 되는 지점이 낮아지므로, 신뢰성이 높은 시스템이라고 할 수 있다. PSK는 어레이가 늘어날 수 록 그래프가 바깥쪽에 위치하게 되므로 신뢰성은 낮아진다고 할 수 있다. gray코딩을 사용했기 때문에 BPSK와 QPSK의 BER성능이 큰 차이가 없는 것을 확인할 수 있다.FSK는 반대로 에레이가 늘어날수록 BER 성능이 좋아지는 모습을 보인다.
디지털 공학 Design Project설계 보고서Design of Excess-3-to-BCD code converter설계 이론1. specification- BCD code 는 4 bit의 binary로 0~9까지의 10진수를 표현한 코드이다. 4개의 bit가 10진수 1자리를 나타 낸다- Excess-3 code 는 각각의 BCD코드에 3씩을 더한 값으로 이뤄진 코드이다. 3~12까지의 10진수 값을 가진다- Excess 3 to BCD는 Excess 3에서 3을 빼는 것이다.- Excess 3 는 4개의 비트로 구성되는데 제일 최하위 비트 순서로 A,B,C,D 로 표시힌다.- 각 BCD 숫자는 4개의 비트로 구성되는데 가장 최상위 비트에서부터 제일 최하위비트 순서로 W,X,Y,Z로 표시한다.2. FormulationTruth tableDecimalExcess-3BCDDigitABCDWXYZ00000××××10001××××20010××××300***************************************100*************1**************************1*************××××141110××××151111××××K-mapCDAB0001111000××0×010000111×××100010W = AB+ACDCDAB0001111000××0×010010110×××101101X = B’C‘+BCD+B’D’CDAB0001111000××0×010101110×××100101Y = C’D+CD’CDAB0001111000××0×011001111×××101001Z = D’3. two-level optimization.K-map을 이용해서 부울함수식을 나타내었다.W = AB+ACDX = B’C‘+BCD+B’D’Y = C’D+CD’Z = D’위의 부울함수식을 이용하여 2-level optimization을 하였다.4. multiple-level optimization.전 CD = X로 치환해서 위의 부울함수식을 간단히 나타낼 수 있다.W = AB+ACD = A(B + X)CD = XX = B’C‘+BCD+B’D’ = B’X’+BXC’+D’ = X’Y = C’D+CD’= (C+D)(C’+D’) = (C+D)X’Z = D’바꾼 부울함수식으로 Multi level optimization을 하였다.5. technology mapping : implementation with NAND gates.Multi Level optimization에서 NAND Gate 로만 매핑을 한다.완성Verilog HDL 설계 진행 : Using Quotus II6. Schemetic diagram 으로 simulator 로 검증한다.schemetic editor로 schemetic diagram을 완성입력 파형의 Waveform file 을 만들어서 functional simulation 하여 검증7. Verilog HDL(1) structural descriptionStructural description의 CodingStructural description의 functional simulation 결과(2) dataflow descriptionDataflow description의 codingDataflow description의 functional simulation 결과(3) behavioral descriptionbehavioral description의 codingbehavioral description의 functional simulation 결과FPGA 설계 진행8. implementationAssignment Editor 를 사용하여 입력, 출력 port 를 FPGA pin 에 assignment 하였다.보드 설명서를 참고하여 input인 A,B,C,D를 순서대로 SW3, SW2, SW1, SW0에 output인 W, X, Y, Z를 순서대로 LEDR3, LEDR2, LEDR1, LEDR0에 assign 하였다.Dataflow description 을 사용하여 recompile 하였다.9. timing simulationTiming simulationTiming simulation