Hi all, I'm writing an app which allows me to load a .out onto my dsp board, and in turn to communicate with my board (C6711DSK). So far I have been successful using handshaking, but I would also like to interrupt the board and I cant seem to get this working. I imagine the problem isn't major, and that I've probably left out something simple. So anyway I guess the best idea is for me to include the code I'm using. Below is my target .out file with I'm loading to the board using my app. As you can see, I'm enabling GIE and INT13's IE - do I need to do anything else? The target .out program processes two hand shaking commands - LEDS_ON and LEDS_OFF, while the interrupt should turn off the leds. #include <stdio.h> #include <c6x.h> #include "c6211dsk.h" #include "cnfDSP.h" #include "dsk6xHSB.h" #pragma DATA_SECTION(handShakingBuffer, "my_DataSect") int handShakingBuffer[HS_BUFFER_LEN]; int newFlag; /*--------------------------*/ /* main() */ /*------------------------*/ int main() { unsigned int io_port_values; /* dsp and peripheral initialization */ CSR=0x100; IER=0x0002; ICR=0xffff; newFlag = 0; *(unsigned volatile int *)EMIF_CE0 = 0x30; /* EMIF CE0control */ /*--------------------------*/ /* Read DIP switches */ /*---------------------------*/ *(unsigned volatile int *)EMIF_CE1 = CE1_32;// EMIF CE1 control, 32bit async io_port_values=get_ioport(); *(unsigned volatile int *)EMIF_CE1 = CE1_8;// EMIF CE1 control, 8bit async /*---------------------------*/ /* Perform Hand Shaking */ /*---------------------------*/ handShakingBuffer[0] = ID_0; handShakingBuffer[1] = ID_1; handShakingBuffer[2] = ID_2; handShakingBuffer[3] = 0; handShakingBuffer[4] = 0; handShakingBuffer[5] = io_port_values; /*---------------------*/ /* Wait for Host ACK */ /*----------------------*/ while(handShakingBuffer[4] != HOST_RECEIVE_HAND_SHAKING_INFO); /*------------------------------ -----*/ /* Reset handShakingBuffer */ /*------------------------------ -----*/ handShakingBuffer[0] = 0; handShakingBuffer[1] = 0; handShakingBuffer[2] = 0; #if PRINT printf("Hand Shake Complete.\n"); #endif CSR=0x1; //set GIE IER=0x2002; //set HPI /*-------------------------*/ /* Run DSP forever */ /*---------------------*/ while(1) { /*-------------------*/ /* Test for HOST ready */ /*-------------------*/ #if PRINT printf("\nDSP Ready for HOST Command.\n"); #endif /*-----------------*/ /* Wait until HOST has a command and parameters ready */ /*------------*/ while(handShakingBuffer[4] != HOST_STATUS_INPUT_READY && handShakingBuffer[4] != HOST_STATUS_END_PROCESSING); /*------------------*/ /* Quit if HOST requests it or Process a HOST command */ /*----------------*/ if(handShakingBuffer[4] == HOST_STATUS_END_PROCESSING) { #if PRINT printf("\nHOST Requested End of Processing.\n"); #endif break; } else { handShakingBuffer[4] = DSP_PROCESSING_COMMAND; } #if PRINT printf("\nNew HOST Command Read: "); #endif /*------------------*/ /* Process a HOST command */ /*-----------------*/ switch(handShakingBuffer[3]) { case LEDS_OFF: *(unsigned volatile int *)EMIF_CE1 = CE1_32;// EMIF CE1 control, 32bit async ledOff(); handShakingBuffer[5]=0;//TIMER_OK; *(unsigned volatile int *)EMIF_CE1 = CE1_8;// EMIF CE1 control, 8bit async break; case LEDS_ON: *(unsigned volatile int *)EMIF_CE1 = CE1_32;// EMIF CE1 control, 32bit async ledOn(); handShakingBuffer[5]=0;//LEDS_OK; *(unsigned volatile int *)EMIF_CE1 = CE1_8;// EMIF CE1 control, 8bit async break; } /*---------------------*/ /* Tell the HOST that DSP processing is done for this command */ /*-----------------*/ handShakingBuffer[4] = DSP_STATUS_OUTPUT_READY; } while(1); return(0); } void ledOn() { *(unsigned volatile int *)IO_PORT = 0x0000000;/* turn on user leds */ } void ledOff() { *(unsigned volatile int *)IO_PORT = 0x7000000;/* turn off user leds */ } /*---------------------*/ /* get_ioport() - used to read state of ioport */ /*--------------------*/ unsigned int get_ioport(void) { return(*(unsigned volatile int *)IO_PORT); } interrupt void hpi_isr() { *(unsigned volatile int *)EMIF_CE1 = CE1_32;// EMIF CE1 control, 32bit async ledOff(); *(unsigned volatile int *)EMIF_CE1 = CE1_8;// EMIF CE1 control, 8bit async } ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// //////////////////// OK, this is my vector table - * * TI Proprietary Information * Internal Data * .ref _hpi_isr .ref _c_int00 .sect "vectors" RESET_RST: mvkl .S2 _c_int00, B0 mvkh .S2 _c_int00, B0 B .S2 B0 NOP NOP NOP NOP NOP NMI_RST: NOP NOP NOP NOP NOP NOP NOP NOP RESV1: NOP NOP NOP NOP NOP NOP NOP NOP RESV2: NOP NOP NOP NOP NOP NOP NOP NOP INT4: NOP NOP NOP NOP NOP NOP NOP NOP INT5: NOP NOP NOP NOP NOP NOP NOP NOP INT6: NOP NOP NOP NOP NOP NOP NOP NOP INT7: NOP NOP NOP NOP NOP NOP NOP NOP INT8: NOP NOP NOP NOP NOP NOP NOP NOP INT9: NOP NOP NOP NOP NOP NOP NOP NOP INT10: NOP NOP NOP NOP NOP NOP NOP NOP INT11: NOP NOP NOP NOP NOP NOP NOP NOP INT12: NOP NOP NOP NOP NOP NOP NOP NOP INT13: b _hpi_isr NOP NOP NOP NOP NOP NOP NOP INT14: NOP NOP NOP NOP NOP NOP NOP NOP INT15: NOP NOP NOP NOP NOP NOP NOP NOP ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /////////////////// Finally the app, which allows the user to turn off or on the leds - #include <stdio.h> #include <windows.h> #include "dsk6x11hpi.h" #include "dsk6xHSB.h" #include "dsk6xtst.h" const ULONG DSPHS_BUFFER_ADDRESS = 0x200; /* Start Int Mem */ static FILE *pBoardFile = NULL; #define STRING_BUFFER_SIZE (80) #define ULONG unsigned long static void PrintMenu( void ); /*-------------------------------- -----*/ /* main () */ /*-------------------------------- -----*/ void main(int argc1, char *argv1[]) { int finished = 0; dskHANDLE hBd; /* Board device handle */ short iBd = 0; /* Board index */ BOOL bExcl = 1; /* Exclusive open = TRUE */ short iMp = 1; /* Map selector = MAP1 */ char coffNam[20]= "CnfDSP.out"; /* COFF file name */ char *sBoardFile; BOOL bVerbose = 0; /* COFF load verbose mode = FALSE */ BOOL bClr = 0; /* Clear bss mode = FALSE */ BOOL bDump = 0; /* Dump mode = FALSE */ ULONG handShakingBuffer[HS_BUFFER_LEN], readLength, writeLength; int handShakingFlag, dspProcFlag; int choice; ULONG command; /* Command variable to run each test on DSP */ /*------------------------------ -----*/ /* Parse Command Line */ /*------------------------------ -----*/ sBoardFile = "F:\\ti\\c6000\\dsk6x11\\doc\\ti_ppdsk.cfg"; pBoardFile = fopen( sBoardFile, "r" ); if ( pBoardFile == NULL ) { printf( "ERROR: Please specify a valid board configuration file via the -f option.\n" ); exit(1); } else { fclose(pBoardFile); } /*---------------------*/ /* Open a driver connection to a dsk6x board. */ /*------------------*/ if ( !dsk6x_open(sBoardFile,&hBd) ) { exit(1); } /*------------*/ /* Cause a DSP reset. */ /*----------*/ if ( !dsk6x_reset_dsp(hBd,0,1) ) { exit(2); } /*----------------------*/ /* Establish a connection to the HPI of a target board. */ /*---------------------*/ if ( !dsk6x_hpi_open(hBd)) { exit(3); } /*----------------------*/ /* Read a COFF file and write the data to DSP memory. */ /*------------------*/ if (dsk6x_coff_load(hBd,coffNam,bVerbose,bClr,bDump)) { exit(4); } /*---------------------*/ /* Generate a DSPINT to start program */ /*---------------------*/ if (!dsk6x_hpi_generate_int(hBd)) { exit(5); } /*--------------------*/ /* Handshaking. Keep reading until hand shake is done. */ /*--------------------*/ do { readLength = HS_BUFFER_LEN*4; /* 4 bytes for 1 word */ /*--------------------*/ /* Test if handShakingBuffer actually read (completely) */ /*-----------------*/ if (!dsk6x_hpi_read(hBd, handShakingBuffer, &readLength, DSPHS_BUFFER_ADDRESS) || readLength != HS_BUFFER_LEN*4) { /* evm6x_hpi_read() failed */ continue; // try again } /*------------------*/ /* Test if handShakingBuffer contains correct ID */ /*---------------------*/ handShakingFlag = 0; // reset hand shaking flag if(handShakingBuffer[0] != ID_0) handShakingFlag = 1; if(handShakingBuffer[1] != ID_1) handShakingFlag = 1; if(handShakingBuffer[2] != ID_2) handShakingFlag = 1; } while (handShakingFlag == 1); /*-------------------*/ /* Send hand shaking ACK to Target (DSP) */ /*-----------*/ writeLength = 4; handShakingBuffer[4] = HOST_RECEIVE_HAND_SHAKING_INFO; dsk6x_hpi_write(hBd, &handShakingBuffer[4], &writeLength, DSPHS_BUFFER_ADDRESS+4*4); /*------------------------*/ /* Display Menu First time */ /*--------------------*/ printf("\nEnter 1 for led off, 2 for leds on, 3 for interupt - leds off, other to escape\n"); /*---------------------*/ /* Do while loop for repeat of choices */ /*-------------------*/ do { printf("\nChoice: "); scanf("%d", &choice); if(choice == 1) command = LEDS_OFF; else if(choice == 2) command = LEDS_ON; else if(choice == 3) dsk6x_hpi_generate_int(hBd); else finished = 1; if(choice!=1||choice!=2) { /*----*/ /* Send command to Target (DSP) */ /*--------------*/ writeLength = 4; handShakingBuffer[3] = command; dsk6x_hpi_write(hBd, &handShakingBuffer[3], &writeLength, DSPHS_BUFFER_ADDRESS+3*4); /*-----------------*/ /* Tell Target(DSP) that Host is ready */ /*---------------*/ writeLength = 4; handShakingBuffer[4] = HOST_STATUS_INPUT_READY; dsk6x_hpi_write(hBd, &handShakingBuffer[4], &writeLength, DSPHS_BUFFER_ADDRESS+4*4); dspProcFlag = 1; /*----------------*/ /* Wait for Target(DSP) to tell you it is done! */ /*-----*/ do { readLength = 4; dsk6x_hpi_read(hBd, &handShakingBuffer[4], &readLength, DSPHS_BUFFER_ADDRESS+4*4); if(handShakingBuffer[4] == DSP_STATUS_OUTPUT_READY) dspProcFlag = 0; // DSP is done processing } while(dspProcFlag); /*---------------*/ /* Test for yes answer to repeat processing */ /*-------------*/ } } while (!finished); /*--------------------*/ /* Tell Target(DSP) that HOST is done! */ /*-------------------------*/ writeLength = 4; handShakingBuffer[4] = HOST_STATUS_END_PROCESSING; dsk6x_hpi_write(hBd, &handShakingBuffer[4], &writeLength, DSPHS_BUFFER_ADDRESS+4*4); /*-----------------------*/ /* Close the new HPI session started with evm6x_hpi_open () */ /*--------------------*/ if (!dsk6x_hpi_close(hBd)) { exit(6); } /*---------------------*/ /* Close a previously opened driver connection to a board. */ /*--------------*/ if (!dsk6x_close(hBd)) { exit(7); } exit(0); } /* end of main() */ |