AnsweredAssumed Answered

ATAPI ADSP-BF548

Question asked by arash on Aug 6, 2012
Latest reply on Aug 26, 2012 by Prashant

Hi everybody,

 

I've been trying to initialize ATAPI in BF548 according to the described protocol in Hardware Reference of BF54x. However, reading the first sector which is information about HDD, I receive zero.

I'm developing the processor using Assembly Code.

The power on self-test code generates 24 errors while building the project, so I can't use it as a reference.

The initializing code is as following:

I wonder if one could tell me how I can tackle this problem.

 

//reset

P0.h = hi(ATAPI_CONTROL);

                                P0.l = lo(ATAPI_CONTROL);

                              R0 = DEV_RST;

                              W[P0] = R0;//reset

                              CALL Wait.Loop;

                                R0 = 0;

                                W[P0] = R0;//reset

  CALL Wait.Loop;

 

 

//read status register

ATAPI.Reset.Wait:

                              CALL ATAPI.Read.Status;

                                  CC = BITTST(R0,7);

                                IF CC JUMP ATAPI.Reset.Wait;

                                CC = BITTST(R0,6);

                                IF !CC JUMP ATAPI.Reset.Wait;

 

 

//DEVICE selection

ATAPI.Dev_Selec.Wait1:

                              CALL ATAPI.Read.Status;

                                 CC = BITTST(R0,7);

                                IF CC JUMP ATAPI.Dev_Selec.Wait1;  

                                CC = BITTST(R0,3);

                                IF CC JUMP ATAPI.Dev_Selec.Wait1;  

                                R1 = 6;

                                R0 = 0x0000;

                                CALL ATAPI.Write.Data;

ATAPI.Dev_Selec.Wait2:

                              CALL ATAPI.Read.Status;

  CC = BITTST(R0,7);

                                IF CC JUMP ATAPI.Dev_Selec.Wait2;  

                                CC = BITTST(R0,3);

                                IF CC JUMP ATAPI.Dev_Selec.Wait2;   

 

//read status register

ATAPI.Parameter.Wait0:

                              CALL ATAPI.Read.Status;

                                 CC = BITTST(R0,7);

                                IF CC JUMP ATAPI.Parameter.Wait0;  

CC = BITTST(R0,3);

  IF !CC JUMP ATAPI.Parameter.Wait0;  

 

                                // IDENTIFY DEVICE

 

                                R1 = 2;

                                R0 = 1;

                                CALL ATAPI.Write.Data;

ATAPI.Parameter.Wait1:

                              CALL ATAPI.Read.Status;

  CC = BITTST(R0,7);

                                IF CC JUMP ATAPI.Parameter.Wait1;  

  CC = BITTST(R0,3);

  IF !CC JUMP ATAPI.Parameter.Wait1;

 

 

                                R1 = 3;

                                R0 = 1;

                                CALL ATAPI.Write.Data;

ATAPI.Parameter.Wait2:

                              CALL ATAPI.Read.Status;

  CC = BITTST(R0,7);

                                IF CC JUMP ATAPI.Parameter.Wait2;  

  CC = BITTST(R0,3);

  IF !CC JUMP ATAPI.Parameter.Wait2;

                                  

                                R1 = 4;

                                R0 = 0;

                                CALL ATAPI.Write.Data;

ATAPI.Parameter.Wait3:

                              CALL ATAPI.Read.Status;

  CC = BITTST(R0,7);

                                IF CC JUMP ATAPI.Parameter.Wait3;  

  CC = BITTST(R0,3);

  IF !CC JUMP ATAPI.Parameter.Wait3;

                                  

                                R1 = 5;

                                R0 = 0;

                                CALL ATAPI.Write.Data;

ATAPI.Parameter.Wait4:

                              CALL ATAPI.Read.Status;

  CC = BITTST(R0,7);

                                IF CC JUMP ATAPI.Parameter.Wait4;  

  CC = BITTST(R0,3);

  IF !CC JUMP ATAPI.Parameter.Wait4; 

 

P0.l = lo(ATAPI_XFER_LEN);

                                R0 = 256;

                                W[P0] = R0;

                                LC0 = R0;

                                P0.l = lo(ATAPI_DEV_ADDR);

                                R0 = 0;

                                W[P0] = R0;

                                P0.l = lo(ATAPI_CONTROL);

                                R0 = 0;

                                W[P0] = R0;

                                P0.l = lo(ATAPI_CONTROL);

                                R0 = PIO_START;

                                W[P0] = R0;

 

 

/**********************/

ATAPI.Read.Status:

                              [--SP] = RETS;

                              [--SP] = P0;

 

 

 

 

Read_Status_ATAPI:

                              P0.h = hi(ATAPI_DEV_ADDR);

                                P0.l = lo(ATAPI_DEV_ADDR);

                                R0 = 0x0007;

                                W[P0] = R0;

                                P0.l = lo(ATAPI_CONTROL);

                                R0 = PIO_START;

                                W[P0] = R0;

Read_Status_Wait.Read.ATAPI:  

                                P0.l = lo(ATAPI_STATUS);

                                R0 = W[P0](Z);

                                CC = BITTST(R0,0);

                                IF CC JUMP Read_Status_Wait.Read.ATAPI;

                                P0.l = lo(ATAPI_DEV_RXBUF);

                                R0 = W[P0](Z);

 

 

 

 

                                P0 = [SP++];

                              RETS = [SP++];

                              RTS;

/**********************/

ATAPI.Read.Data:

                              [--SP] = RETS;

                              [--SP] = P0;

 

 

 

 

 

Read_Data_ATAPI:

                              P0.h = hi(ATAPI_DEV_ADDR);

                                P0.l = lo(ATAPI_DEV_ADDR);

                                R0 = 0x0000;

                                W[P0] = R0;

                                P0.l = lo(ATAPI_CONTROL);

                                R0 = PIO_START;

                                W[P0] = R0;

Read_Data_Wait.Read.ATAPI:  

                                P0.l = lo(ATAPI_STATUS);

                                R0 = W[P0](Z);

                                CC = BITTST(R0,0);

                                IF CC JUMP Read_Data_Wait.Read.ATAPI;

                                P0.l = lo(ATAPI_DEV_RXBUF);

                                R0 = W[P0](Z);

                                CC = BITTST(R0,7);

 

 

 

                                P0 = [SP++];

                              RETS = [SP++];

                              RTS;

/**********************/

ATAPI.Write.Data:

                              [--SP] = RETS;

                              [--SP] = P0;

                              //R0 value

                              //R1 address

 

 

Write_Status_ATAPI:

                              P0.h = hi(ATAPI_DEV_ADDR);

                                P0.l = lo(ATAPI_DEV_ADDR);

                                 W[P0] = R1;

                                P0.l = lo(ATAPI_DEV_TXBUF);

                                W[P0] = R0;

                                P0.l = lo(ATAPI_CONTROL);

                                R0 = PIO_START|XFER_DIR;

                                W[P0] = R0;

Write_Status_Wait.Read.ATAPI:  

                                P0.l = lo(ATAPI_STATUS);

                                R0 = W[P0](Z);

                                CC = BITTST(R0,0);

                                IF CC JUMP Write_Status_Wait.Read.ATAPI;

 

                                P0 = [SP++];

                              RETS = [SP++];

                              RTS;

Outcomes