怎么样才能知道读写寄存器成功呢?
我按照官方资料上的测试程序
/* Test 1 - check ADSR and ISR0 by programming to talk with 'ton' */
struct ck t1[] = {
{WT, tauxmr,0x15}, /* switch to 9914 mode */
{WT, auxcr, 0x1c}, /* reset chip */
{WT, auxcr, 0x80}, /* reset chip */
{WT, auxcr, 0x00}, /* reset chip */
{WT, auxcr, 0x1e}, /* page in to imr2 */
{WT, imr2, 0x00}, /* clear GLINT bit and imr2*/
{WT, imr1, 0x00}, /* clear imr1 */
{WT, imr0, 0x00}, /* clear imr0 */
{WT, auxcr, 0x8a}, /* 'ton' */
{RD, isr0, 0x10}, /* BO bit set - no interrupts */
{RD, isr1, 0x00},
{RD, adsr, 0x02}, /* 9914A is TADS */
{WT, auxcr, 0x0a}, /* clear 'ton' */
{RD, adsr, 0x00}, /* TADS cleared */
{0}};
我读出来的数据一直都是不对的。
硬件连接时这样的
读写子程序是
void outp(unsigned char abc,unsigned char o_data)
{unsigned char xdata *io_address;
io_address=abc<<8;
*io_address = o_data;
}
unsigned char inp(unsigned char abc)
{unsigned char temp;
unsigned char xdata *io_address;
io_address=abc<<8;
temp= *io_address ;
return temp;
}
RS0-2接的是P2.0-2
void outp(unsigned char abc,unsigned char o_data)
{unsigned char xdata *io_address;
io_address=abc<<8;
*io_address = o_data;
}
unsigned char inp(unsigned char abc)
{unsigned char temp;
unsigned char xdata *io_address;
io_address=abc<<8;
temp= *io_address ;
return temp;
}
#define Base_Address 0x00
/* define i/o addresses of the registers on the nat9914 */
#define r_isr0 (Base_Address )
#define r_imr0 (Base_Address )
#define r_isr1 (Base_Address+1 )
#define r_imr1 (Base_Address+1 )
#define r_adsr (Base_Address+2 )
#define r_imr2 (Base_Address+2 )
#define r_eosr (Base_Address+2 )
#define r_bcr (Base_Address+2 )
#define r_accr (Base_Address+2 )
#define r_bsr (Base_Address+3 )
#define r_auxcr (Base_Address+3 )
#define r_isr2 (Base_Address+4 )
#define r_adr (Base_Address+4 )
#define r_spmr (Base_Address+5)
#define r_spsr (Base_Address+5)
#define r_cptr (Base_Address+6)
#define r_ppr (Base_Address+6)
#define r_dir (Base_Address+7)
#define r_cdor (Base_Address+7)
高手帮帮忙
看下错误在哪里 |