📄 bdm.c
字号:
/* 4.5 - 6.5 MHz */
unsigned char bdm_rx3(void) {
#pragma NO_RETURN
asm {
LDA #RESET_OUT_MASK /* contents of A will be driven to PTA in order to switch the driver off */
CLRX /* prepare HX to point to PTA */
CLRH
/* bit 7 (MSB) */
mov #0x10,0
//STX ,X /* drive BDM low */
STA ,X /* switch BDM to high impedance */
BIT ,X /* wait 2 cycles */
LDX ,X /* load X with value on the PTA port (including BDM_IN) */
PSHX /* store the value on the stack */
CLRX /* clear X again */
/* bit 6 */
mov #0x10,0
//STX ,X /* drive BDM low */
STA ,X /* switch BDM to high impedance */
BIT ,X /* wait 2 cycles */
LDX ,X /* load X with value on the PTA port (including BDM_IN) */
PSHX /* store the value on the stack */
CLRX /* clear X again */
/* bit 5 */
mov #0x10,0
//STX ,X /* drive BDM low */
STA ,X /* switch BDM to high impedance */
BIT ,X /* wait 2 cycles */
LDX ,X /* load X with value on the PTA port (including BDM_IN) */
PSHX /* store the value on the stack */
CLRX /* clear X again */
/* bit 4 */
mov #0x10,0
//STX ,X /* drive BDM low */
STA ,X /* switch BDM to high impedance */
BIT ,X /* wait 2 cycles */
LDX ,X /* load X with value on the PTA port (including BDM_IN) */
PSHX /* store the value on the stack */
CLRX /* clear X again */
/* bit 3 */
mov #0x10,0
//STX ,X /* drive BDM low */
STA ,X /* switch BDM to high impedance */
BIT ,X /* wait 2 cycles */
LDX ,X /* load X with value on the PTA port (including BDM_IN) */
PSHX /* store the value on the stack */
CLRX /* clear X again */
/* bit 2 */
mov #0x10,0
//STX ,X /* drive BDM low */
STA ,X /* switch BDM to high impedance */
BIT ,X /* wait 2 cycles */
LDX ,X /* load X with value on the PTA port (including BDM_IN) */
PSHX /* store the value on the stack */
CLRX /* clear X again */
/* bit 1 */
mov #0x10,0
//STX ,X /* drive BDM low */
STA ,X /* switch BDM to high impedance */
BIT ,X /* wait 2 cycles */
LDX ,X /* load X with value on the PTA port (including BDM_IN) */
PSHX /* store the value on the stack */
CLRX /* clear X again */
/* bit 0 */
mov #0x10,0
//STX ,X /* drive BDM low */
STA ,X /* switch BDM to high impedance */
BIT ,X /* wait 2 cycles */
LDX ,X /* load X with value on the PTA port (including BDM_IN) */
/* now get the bit values (last value is in X, previous 7 on stack) */
JMP rx_stack_decode
}
}
/* 3.86 - 5.57 MHz */
unsigned char bdm_rx4(void) {
#pragma NO_RETURN
asm {
LDA #RESET_OUT_MASK /* contents of A will be driven to PTA in order to switch the driver off */
CLRX /* prepare HX to point to PTA */
CLRH
/* bit 7 (MSB) */
mov #0x10,0
//STX ,X /* drive BDM low */
STA ,X /* switch BDM to high impedance */
BRN 0 /* wait 3 cycles */
LDX ,X /* load X with value on the PTA port (including BDM_IN) */
PSHX /* store the value on the stack */
CLRX /* clear X again */
NOP /* wait 1 cycle */
/* bit 6 */
mov #0x10,0
//STX ,X /* drive BDM low */
STA ,X /* switch BDM to high impedance */
BRN 0 /* wait 3 cycles */
LDX ,X /* load X with value on the PTA port (including BDM_IN) */
PSHX /* store the value on the stack */
CLRX /* clear X again */
NOP /* wait 1 cycle */
/* bit 5 */
mov #0x10,0
//STX ,X /* drive BDM low */
STA ,X /* switch BDM to high impedance */
BRN 0 /* wait 3 cycles */
LDX ,X /* load X with value on the PTA port (including BDM_IN) */
PSHX /* store the value on the stack */
CLRX /* clear X again */
NOP /* wait 1 cycle */
/* bit 4 */
mov #0x10,0
//STX ,X /* drive BDM low */
STA ,X /* switch BDM to high impedance */
BRN 0 /* wait 3 cycles */
LDX ,X /* load X with value on the PTA port (including BDM_IN) */
PSHX /* store the value on the stack */
CLRX /* clear X again */
NOP /* wait 1 cycle */
/* bit 3 */
mov #0x10,0
//STX ,X /* drive BDM low */
STA ,X /* switch BDM to high impedance */
BRN 0 /* wait 3 cycles */
LDX ,X /* load X with value on the PTA port (including BDM_IN) */
PSHX /* store the value on the stack */
CLRX /* clear X again */
NOP /* wait 1 cycle */
/* bit 2 */
mov #0x10,0
//STX ,X /* drive BDM low */
STA ,X /* switch BDM to high impedance */
BRN 0 /* wait 3 cycles */
LDX ,X /* load X with value on the PTA port (including BDM_IN) */
PSHX /* store the value on the stack */
CLRX /* clear X again */
NOP /* wait 1 cycle */
/* bit 1 */
mov #0x10,0
//STX ,X /* drive BDM low */
STA ,X /* switch BDM to high impedance */
BRN 0 /* wait 3 cycles */
LDX ,X /* load X with value on the PTA port (including BDM_IN) */
PSHX /* store the value on the stack */
CLRX /* clear X again */
NOP /* wait 1 cycle */
/* bit 0 */
mov #0x10,0
//STX ,X /* drive BDM low */
STA ,X /* switch BDM to high impedance */
BRN 0 /* wait 3 cycles */
LDX ,X /* load X with value on the PTA port (including BDM_IN) */
/* now get the bit values (last value is in X, previous 7 on stack) */
JMP rx_stack_decode
}
}
/* 3.38 - 4.48 MHz */
unsigned char bdm_rx5(void) {
#pragma NO_RETURN
asm {
LDA #RESET_OUT_MASK /* contents of A will be driven to PTA in order to switch the driver off */
//LDA #BDM_DIR1_MASK+RESET_OUT_MASK /* contents of A will be driven to PTA in order to switch the driver off */
CLRX /* prepare HX to point to PTA */
CLRH
/* bit 7 (MSB) */
mov #0x10,0
//STX ,X /* drive BDM low */
//NOP /* wait 1 cycle */
STA ,X /* switch BDM to high impedance */
BRN 0 /* wait 3 cycles */
LDX ,X /* load X with value on the PTA port (including BDM_IN) */
PSHX /* store the value on the stack */
CLRX /* clear X again */
BIT ,X /* wait 2 cycles */
/* bit 6 */
mov #0x10,0
//STX ,X /* drive BDM low */
//NOP /* wait 1 cycle */
STA ,X /* switch BDM to high impedance */
BRN 0 /* wait 3 cycles */
LDX ,X /* load X with value on the PTA port (including BDM_IN) */
PSHX /* store the value on the stack */
CLRX /* clear X again */
BIT ,X /* wait 2 cycles */
/* bit 5 */
mov #0x10,0
//STX ,X /* drive BDM low */
//NOP /* wait 1 cycle */
STA ,X /* switch BDM to high impedance */
BRN 0 /* wait 3 cycles */
LDX ,X /* load X with value on the PTA port (including BDM_IN) */
PSHX /* store the value on the stack */
CLRX /* clear X again */
BIT ,X /* wait 2 cycles */
/* bit 4 */
mov #0x10,0
//STX ,X /* drive BDM low */
//NOP /* wait 1 cycle */
STA ,X /* switch BDM to high impedance */
BRN 0 /* wait 3 cycles */
LDX ,X /* load X with value on the PTA port (including BDM_IN) */
PSHX /* store the value on the stack */
CLRX /* clear X again */
BIT ,X /* wait 2 cycles */
/* bit 3 */
mov #0x10,0
//STX ,X /* drive BDM low */
//NOP /* wait 1 cycle */
STA ,X /* switch BDM to high impedance */
BRN 0 /* wait 3 cycles */
LDX ,X /* load X with value on the PTA port (including BDM_IN) */
PSHX /* store the value on the stack */
CLRX /* clear X again */
BIT ,X /* wait 2 cycles */
/* bit 2 */
mov #0x10,0
//STX ,X /* drive BDM low */
//NOP /* wait 1 cycle */
STA ,X /* switch BDM to high impedance */
BRN 0 /* wait 3 cycles */
LDX ,X /* load X with value on the PTA port (including BDM_IN) */
PSHX /* store the value on the stack */
CLRX /* clear X again */
BIT ,X /* wait 2 cycles */
/* bit 1 */
mov #0x10,0
//STX ,X /* drive BDM low */
//NOP /* wait 1 cycle */
STA ,X /* switch BDM to high impedance */
BRN 0 /* wait 3 cycles */
LDX ,X /* load X with value on the PTA port (including BDM_IN) */
PSHX /* store the value on the stack */
CLRX /* clear X again */
BIT ,X /* wait 2 cycles */
/* bit 0 */
mov #0x10,0
//STX ,X /* drive BDM low */
//NOP /* wait 1 cycle */
STA ,X /* switch BDM to high impedance */
BRN 0 /* wait 3 cycles */
LDX ,X /* load X with value on the PTA port (including BDM_IN) */
/* now get the bit values (last value is in X, previous 7 on stack) */
JMP rx_stack_decode
}
}
/* 2.7 - 3.9 MHz */
unsigned char bdm_rx6(void) {
asm {
LDA #RESET_OUT_MASK /* contents of A will be driven to PTA in order to switch the driver off */
//LDA #BDM_DIR1_MASK+RESET_OUT_MASK /* contents of A will be driven to PTA in order to switch the driver off */
CLRX /* prepare HX to point to PTA */
CLRH
/* bit 7 (MSB) */
mov #0x10,0
//STX ,X /* drive BDM low */
//NOP /* wait 1 cycle */
STA ,X /* switch BDM to high impedance */
BRSET 0,DDRA,0 /* wait 5 cycles */
LDX ,X /* load X with value on the PTA port (including BDM_IN) */
LSLX /* shift BDM_IN into C */
LSLX
CLRX /* clear X again */
BRN 0 /* wait 3 cycles */
/* bit 6 */
mov #0x10,0
//STX ,X /* drive BDM low */
//NOP /* wait 1 cycle */
STA ,X /* switch BDM to high impedance */
ROL i /* shift C into i (from the bottom) */
NOP /* wait 1 more cycle (5 cycles in total together with ROL) */
LDX ,X /* load X with value on the PTA port (including BDM_IN) */
LSLX /* shift BDM_IN into C */
LSLX
CLRX /* clear X again */
BRN 0 /* wait 3 cycles */
/* bit 5 */
mov #0x10,0
//STX ,X /* drive BDM low */
//NOP /* wait 1 cycle */
STA ,X /* switch BDM to high impedance */
ROL i /* shift C into i (from the bottom) */
NOP /* wait 1 more cycle */
LDX ,X /* load X with value on the PTA port (including BDM_IN) */
LSLX /* shift BDM_IN into C */
LSLX
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -