|
Read-Only
Author Claudionor Santos
Posted 18-May-2012 14:43 GMT
Toolset C51
|
 RE: this is ridiculous
Claudionor Santos
Erik
it is a assembly code.
full code :
#define Result_final 0f8h
;*********** Tabela de EQU para as Variaveis em RAM
VEZES EQU 8 ; conta o número de vezes de interrupçao I2C
;********************************************************************
; ENDERECO DE DESVIO SAIDA DE RESET
cseg at 0000h
AJMP 200h
;********************************************************************
; ENDERECO DE DESVIO DA INTERRUPCAO INT0
;cseg at 0003h
;AJMP 0050h
;*********************************************************************
;********************************************************************
; ENDERECO DE DESVIO DA INTERRUPCAO DO TIMER/COUNTER 0
;cseg at 000Bh
;AJMP 0050h
; ENDERECO DE DESVIO DA INTERRUPCAO DO INT1
;cseg at 0013h
;AJMP 0070h
;*********************************************************************
;*********************************************************************
; ENDERECO DE DESVIO DA INTERRUPCAO DO TIMER/COUNTER 1
;cseg at 001Bh
;AJMP 0070h
;*********************************************************************
; ENDERECO DE DESVIO DA INTERRUPCAO DO CANAL I2CSM
cseg at 02Bh ; I2CSM interruption
AJMP 100h
;*********************************************************************
;*********************************************************************
; ENDERECO DE DESVIO DA INTERRUPCAO DO CANAL SERIAL
;cseg at 0023h ;serial interruption
; AJMP 0100h
;*********************************************************************
;*********************************************************************
cseg at 100h
MOV 0F0h, 0E8h ; MOVES STATUS REG TO ACCUMULATOR
jb 0F1h, msb_interrupt ; Status Register bit 1 - E8.1
jb 0F0h, lsb_interrupt ; Status Register bit 0 - E8.0
jb 0F2h, nack_interrupt ; Status Register bit 2 - E8.2
mov R2, 0E8h
cjne R2, #042h, test_lsb_interrupt
ajmp msb_interrupt
test_lsb_interrupt:
cjne R2, #041h, test_nack_interrupt
ajmp lsb_interrupt
test_nack_interrupt:
cjne R2, #044h, error_detected
ajmp nack_interrupt
error_detected:
ajmp error_02
msb_interrupt:
mov R0, 84h
mov 0E8h, #80h ; FLAG Clear - E8 . Clear Interruption Flag
inc VEZES ; Incrementa o contador de interrupçoes
cjne R0, #0A2h, error_03
reti
lsb_interrupt:
mov R0, 85h
mov 0E8h, #80h ; FLAG Clear - E8 . Clear Interruption Flag
inc VEZES ; Incrementa o contador de interrupçoes
cjne R0, #0F8h, error_04
setb ACC.0
reti
nack_interrupt:
mov R0, 84h
mov 0E8h, #80h ; FLAG Clear - E8 . Clear Interruption Flag
inc VEZES ; Incrementa o contador de interrupçoes
cjne R0, #0F8h, error_04
setb ACC.1
reti
error_02:
mov 30h , R2
mov 31h , 0E8h
mov Result_final, #003h ;Interrupt error
error_03:
mov 32h , R2
mov 33h , 0E8h
mov Result_final, #003h ;Recieve error
error_04:
mov 34h , R2
mov 35h , 0E8h
mov Result_final, #003h ;Bit 8 receive error
;*********************************************************************
; Configure 8031
;*********************************************************************
cseg at 200h
SETUP_MCU:
clr RS0;
clr RS1;
mov R0, VEZES
mov A, R0
CJNE A,#0,MAIN_LOOP
mov PSW, #00h ; Move o valor do reg. PSW para 00h
mov IE, #0C0h ; Move o valor de C0h para IE, Habilita Interrupcao do I2CSM
mov PCON, #000h
mov VEZES, #001h ; inicializa o contador de interrupcoes I2C
mov ACC, #000h
;*********************************************************************
; Start tranmission test
;*********************************************************************
mov 0D8H, #001h ;--->>> Reg D8h não implementado I2CSM Habilitado
mov 0D9h, #000h ;--->>> Reg D9h não implementado I2CSM Standard Mode D9h
mov 84h, #0A2h ;I2CSM Slave Address 0xA2 , Write Mode
mov 85h, #0F8h ;I2CSM Write Data 0xF8
mov R5 , 84h
mov R6 , 85h
mov SP, #10h
MAIN_LOOP:
mov R4 , 0E8h
CJNE R4,#42,continue_MAIN_LOOP
nop
nop
nop
ajmp error_01
continue_MAIN_LOOP:
jnb ACC.1, CHECK_I2C_LSB_INT_DONE;
mov R3, VEZES ; CHECK_I2C_NACK_INTERRUPTION
CJNE R3,#02,error_01
ajmp test_completed
CHECK_I2C_LSB_INT_DONE:
jnb ACC.0, MAIN_LOOP;
mov R3, VEZES
CJNE R3,#03,error_01
test_completed:
mov Result_final, #001h ;Test complet sussesfuly
error_01:
mov 36h , R3
mov Result_final, #003h ;Bit 8 receive error
END
|
|
Read-Only
Author Al Bradford
Posted 19-May-2012 00:05 GMT
Toolset C51
|
 RE: How can i create a new device in the database?
Al Bradford
To answer the original question. You can modify some things in a
device data base. First go to File -> Device DataBase... and open
the dialog. Carefully select a device as near to your device as
possible(carefully read the device descriptions). To make a copy of
the existing device data base, change the name, device family and
device type to your device names, etc. Modify the any data necessary
and click the Update AND the the ADD button. At this point you can
define the register .h files that you have created to define your
register set. This is just your Regxxx.h file that you have created.
You can change other device descriptions as necessary.
Now the real hard part. If you have peripherals not common to the
device that you select to change, you must write your own peripheral
types using the AGSI and/or the AGDI features in this toolset. These
new tools will be written in C++ external to the Keil Tools and you
will create a new .dll for your simulator. Templates are availble on
this website.
All of this is described in detail in the PK51 User's Manuals at
this website. You must read and study these manuals carefully to
implement any serious changes to the Device Database.
Good Luck. You will need it.
Bradford
|