星期五, 5月 08, 2009

EE3120 (B) MP & ASSEMBLY LANGUAGE PROG (02EE3120) Assignment 2 Solution

Assignment 2 Solution 2008/9
Question 1 (34 marks)

Answer 1(a)(i)In asynchronous serial transmission, the transmitter's clock and receiver's clock are not synchronized. In order toreceive data correctly, it is necessary to define a protocol on how the data are packed, how many bits constitute acharacter, and when the data begins and ends. Generally, this is done by placing a character between start and stopbits as shown in the following figure. This is called framing.Framing ASCII “A”(41H)When a start bit is received, the receiver will delay a fixed amount of clock cycles which is roughly equal to thehalf period of the data bit width, then sample the data line at roughly the middle of the data bit. If the clockfrequencies for the transmitter and receiver ends are close enough, this provides highly reliable data reception.However, both parties must agree upon the same number of data bits and parity bits in a frame.[5 marks]Answer 1(a)(ii)In 8-bit UART variable mode, the shift clock is derived from the system (x'tal frequency) clock through a series ofdividers shown in the figure below. First the system oscillating frequency will be divided by 12. Timer 1 whichhas to be programmed into 8-bit auto reload model is the second stage of clock division. The dividing constant isdetermined by the value stored in TH1 register. The overflow clock is further divided by 2 if the SMOD bit in thePCON register is 0, otherwise no division is result. Finally, the clock will be divided by 16 before entering into theserial port shift clock. The baud rate can be computed according to the formula:Baud rate =2SMOD32 12 (256-TH1)osc × f× ×Assuming system clock is 11.0592MHz and SMOD=0, for a value of TH 1=253 (i.e., -3 in 8-bit sign integer), thebaud rate is20 11.0592 10632 12 (256-253)× ×× × =9600[6 marks]Answer 1(a)(iii)Main:Continue:Wait:Forever:Sting:Answer 1(b)(i)ORG 0200HMOV DPTR, #StringMOV TMOD, #20HMOV THl,#-24MOV SCON, #50HSETB TR1CLR AMOVC A, @A+DPTRJZ ForeverMOV SBUF, AJNB TI, WaitCLR TIINC DPTRSJMP ContinueSJMP ForeverORG 0400HDB "City University of Hong Kong", 0END; load DPTR with String address; Timer 1, 8-bit auto reload; 1200 baud; 8-bit UART variable; start Timer 1; Read character of Sting»; write to serial port; wait for TI to set; wait TI; increase pointer; continue to transmit next char; do nothing[8 marks]Vector-table approach to interrupt handling is to assign a fixed location in program memory for storing the jumpvector for each interrupt source. When an interrupt happens, processor will finish the current instruction and savethe PC value on stack and then jump to the corresponding location according to the interrupt source. Generally, ajump instruction to the starting address of the interrupt service routine (ISR) will perform. In the case of 8051,there are six interrupt sources including RESET. We can place a LJMP ISR_Address instruction in thecorresponding location. For example, the following instructions put a jump vector for timer 0 interrupt:ORG 0000BHLJMP Timer1_ ISRTimerl1_ISR:ORG 0100H............RETISince the gap between interrupt vectors (except RESET) is eight bytes, we can put the interrupt service routinedirectly in the jump vector location if the size of its ISR is less than or equal 8 bytes. This helps to speed upinterrupt handling for fast real time response.Interrupt ROM Location (Hex) Pin[5 marks]Flag ClearingReset 0000 9 AutoExternal hardware interrupt 0 (INTO) 0003 P3.2(12) AutoTimer 0 interrupt (TFO) 000B AutoExternal hardware interrupt 1 (INT1) 0013 P3.3(13) AutoTimer 1 interrupt (TF1) 001B AutoSerial COM interrupt (RI and TI) 0023 Programmer clears it.Answer 1(b)(ii)ORG 0000H ; Reset vectorLJMP Main;ORG 000BH ; Timer 0 interrupt vectorCPL P2.1 ; toggle P2.1 for square wave outputRETI ; return from ISR;ORG 0023H ; Serial port interrupt vectorLJMP Serial ; jump to serial ISRRETIMain: ORG 0030HMOV P1,#OFFH ; make P1 an input portMOV TMOD, 22H ; timer 0 and 1 are 8-bit auto reloadMOV TH1,#-12 ; 1200 baud rateMOV SCON, #50H ; 8-bit UART with REN enableMOV THO, #-46 ; period for 10 kHz square waveMOV IE, #92H ; enable serial and timer 0 interruptsSETB TR1 ; start timer 1SETB TRO ; start timer 0Back: MOV A, P1 ; read data from Port 1MOV SBUF, A ; write it out to serial portSJMP Back ; loop indefinitely;ORG 0100H ; serial ISR locationSerial: JB TI, Trans ; jump if tx interrupt otherwise rxinterruptMOV A, SBUF ; get the received dataMOV P0,A ; and write it to P0CLR RI ; clear RI (non auto-cleaning)RETI ; return from ISRTrans: CLR TI ; clear TI (non auto-cleaning)RETI ; return from ISREND[10 marks]Question 2 (34 marks)Answer 2(a)ALE is the address latch enable signal output from the 8051 family of microcontrollers. It is a pulse for latching the low-order byte of taccesses to external memory or I/O. Because the low-order byte address (AO-A7) is time-multiplexed with the data (DO-D7) on the phyAD7). A latch, e.g. 74LS373, can be used to latch the address (AO-A7), while data bus (DO-D7) will be available after the addrefollowing circuit can be used. The advantage of using multiplexed bus in 8051 is to save a number of physical pin sfor the chip to codevices. However, by doing so, the speed of external access will be reduced because address and data are multiplexed on the sameaddress has to be latched first, then come the data.[6 marks]Answer 2(b)(i)ROM with an address range 0000 - 3FFF has a size of 16 kbytes. EPROM with an address range 0000 -1FFF has a size of 8 kbytes; RAM with an address range COOO - DFFF has a size of 8 kbytesROM chip required is 1 EPROM chip required is 1 RAM chiprequired is 2[5 marks]Answer 2(b)(ii)[11 marks]Answer 2(b)(iii)

星期三, 5月 06, 2009

Step for reset ESDA password

學校大約一年便會使用ESDA一次,所以忘記了系統管理員密碼並不奇怪。
既然ESDA是用MYSQL儲存數據,那麼重設密碼並不是難事了。

1. 到 c:\Program Files\esda\mysql\bin>
2. 輸入以下指令:
Step1: mysql –u sep
Step2: use sep;
Step3: update users set password='admin' where loginid='admin';
3. 密碼變更為「admin」成功.

星期四, 4月 30, 2009

H3C Ethernet Switches 設定

以前上課時,學習使用的是CISCO的Switch。
但是社會上有多少企業會花錢買較貴的cisco switch?

cisco 以下,就數3com,然後便是h3c了。
雖然名義上 3com 和 h3c 是同一集團,
但是各方面 3com 的也是稍勝一籌。

閒話少說,買了h3c的 S5100-48P-SI 和 S5500-28C-EI 的 Ethernet Switch,
看了英文說明書也等如白看...
幸好上網搜尋3100的設定也合用。

system-view
[H3C] dis cur
[H3C]quit
save
[H3C]local-user admin
[H3C-]password simple 123
[H3C-]service-type telnet
[H3C-]level 3
[H3C-]quit
[H3C]user-interface vty 0 4
[H3C-]authentication-mode scheme
[H3C-]quit

這樣使用switch的ip進入switch的GUI mode,
login name: admin
password: 123
便可以作更簡明的設置了。

星期一, 4月 20, 2009

Windows 7 一談

有傳 window 7 將於五月正式推出,那麼先談window 7有甚麼特別之處。

首先在開機方面,window 7 的速度稍勝,
而在視窗安裝及關機方面,window 7更是明顯快得多。(當然安裝方面我是用usb 手指的)

在安裝硬件方面,因為 window 7 標榜已自帶極大多數的驅動程式,
故比 window 7 來說,driver cd 基本上没有用處。

在華麗的界面方面, window 7 顯然比 window vista 更好。
有些特別effect,如將 internet explorer 畫面拉向螢幕最右方,
它便已讓你預覽將會靠右的垂直並排。

另外 window 7 更有一個特別的 help 功能。
例如以往的 window 如果使用內置的疑難排解,
所提供的解決方法未必切合大家。
但 window 7 便不同了,假若你不小心將音量調至靜音,
但後來發現電腦沒有聲音,當你使用 window 7 的內置工具時,
它會自動先幫你檢查設定,其時便會建議你可以先嘗試解除靜音選項,
且更可以直接帶你到音量設定畫面讓你更方便去設定。

即使你不大了解電腦有甚麼問題,你也可以啟用內置的記錄功能,
它可以將你的所有動作,包括滑鼠及鍵盤操作記錄下來,
更可匯出成一份類似user manual形式的文件。[以後製作教學豈不是易事?]
將該文件交與電腦知識較強的人,便可由他去診斷問題了。



而如果想升級至window 7,有數點必須注意:
1. window xp 和 window 7 的核心不同,亦不支援直接升級。(始終相隔了那麼多年)
2. win vista 可直接升級為 win 7,但請留意可以升等級而不可以降等級。(我所說的是 home/pro 的版本)
3. 當然閣下可以由win xp升為win vista再轉為win 7,但因為很多win xp的檔案對win 7而言是垃圾,那又可必要浪費磁碟空間?
所以可以的話建議直接重裝成win 7吧。

星期三, 4月 08, 2009

邊隻防毒最好用??

網上搵到好多10大排行,但係邊d可信性高?
以下資料較合適中小企業:

Symantec
-有人試過裝完endpoint 11 個server 不勝付荷
-會ban usb 手指save 野
-標榜全面性
-容易被病毒破壞
-中了毒都掃得出來卻清不了
-d client機成日無啦啦斷左, 變左無update,結果就要死死地氣去client機度剷過再裝.........

NOD32
-好多手指毒nod都detect唔到
-對木馬唔夠敏感
-出名快同佔用資源少
-速度快 但係掃毒就差d
-試過nod32, 中左, 掃到剷唔到........開埋安全模式都唔得..........

Kaspersky
-卡巴搵毒勁 速度一般
-有時佢會嚴重誤殺

星期四, 3月 12, 2009

Nokia 5800 mac address 尋找方法

基於確保無線網絡的安全,大部份無線網絡需要透過核對設備的MAC地址後才讓使用者連到網絡。但nokia 5800 xpressmusic 如何才能找到它的MAC地址?


1. 於機盒貼紙上標明

2. 輸入 *#62209526#

星期六, 3月 07, 2009

ESDA 安裝失敗

ESDA 可以說是 APASO 的新版本。

本來安裝EDB的ESDA一切正常,但到最後卻顯示了以下訊息:

make_sock: could not bind to port 0.0.0.0:80

No installed service named"Apache2"


初時懷疑是安裝設定問題,後來曾經嘗試重裝但情況一樣。
因為本機沒有安裝iis所以應該不會佔用 port 80,
但於 "執行" 中輸入 cmd,再輸入netstat -anb,
便發現有其他程式佔用了 port 80。

關掉該程序後,於命令提示字元cd至Apache的資料夾

cd C:\Program Files\Apache Group\Apache2
cd bin
apache -k install
apache -k start



這樣便成功了。

推薦此文