Hello all, I have a problem using ISD51 to debug my board with C515C processor. In order to test the serial port and basic ISD51 functionality, I used a small piece of code below (Test.c). First under the Keil PK51 software simulator, it works fine. I could use the Hyperterminal to receive or to send any character to my board. Then I switched from simulator to Keil In-System ISD51 Debug and it failed. I don't know why as I tried everything in Keil's online documentation. One thing I need to point out is that I didn't burn the code into flash and instead used a flash simulator Flex III. Can someone giveme a hand with this issue? Thanks in advance, Frank /*------------------------------------------------------------------------------ TEST.C: ISD51 Demo for Infineon C868 Copyright 2003 Keil Software, Inc. ------------------------------------------------------------------------------*/ #include <intrins.h> #include <stdio.h> #include "ISD51.h" #include "reg515a.h" /* parameters to initialize serial communication */ #define B_38400 0x05 /* 38400 baud */ #define B_19200 0x04 /* 19200 baud */ #define B_9600 0x03 /* 9600 baud */ #define B_4800 0x02 /* 4800 baud */ #define B_2400 0x01 /* 2400 baud */ #define B_1200 0x00 /* 1200 baud */ void Delay(unsigned int i) { unsigned int j; while(i--) { // delay WDT = 1; // reset SWDT = 1; j = 0x200; while (j--); } } void Project_Init(serBaud) { switch ( serBaud ) { /* oscillator frequency = 10 Mhz */ case B_38400: SRELH = 0x03; /* Reloadwert für 38400 Baud */ SRELL = 0xF0; PCON |= 0x80; /* SMOD = 1 */ break; case B_19200: SRELH = 0x03; /* Reloadwert für 19200 Baud */ SRELL = 0xDF; PCON |= 0x80; /* SMOD = 1 */ break; case B_9600: SRELH = 0x03; /* Reloadwert für 9600 Baud */ SRELL = 0xBF; PCON |= 0x80; /* SMOD = 1 */ break; case B_4800: SRELH = 0x03; /* Reloadwert für 4800 Baud */ SRELL = 0x7E; PCON |= 0x80; /* SMOD = 1 */ break; case B_2400: SRELH = 0x02; /* Reloadwert für 2400 Baud */ SRELL = 0xFC; PCON |= 0x80; /* SMOD = 1 */ break; case B_1200: SRELH = 0x01; /* Reloadwert für 1200 Baud */ SRELL = 0xF7; PCON |= 0x80; /* SMOD = 1 */ break; default: return; break; } ADCON0 |= 0x80; /* enable baud rate generator */ SCON = 0x50; /* mode 1: 8-bit UART, enable receiver */ // ES = 1; /* enable serial interrupt IE.ES */ } #if 1 // uncomment this function to verify serial communication /* * Test Function: verify serial communication with HyperTerminal */ void TestSerial (void) { char c = 'A'; TI = 1; while (1) { Delay(200); if (RI) { c = SBUF; RI = 0; } while (!TI); TI = 0; SBUF = c; } } #endif void main (void) { unsigned int i; Project_Init(B_9600); // Initialize Chip and Serial Interface #ifndef ISD51 // init ISD51 only when the uVision2 Debugger tries to connect TestSerial(); #endif #if 0 // init ISD51 and start user program until the uVision2 Debugger connects ISDinit (); // initialize uVision2 Debugger and continue program run #endif #if 0 // init ISD51 and wait until the uVision2 Debugger connects ISDwait (); // wait for connection to uVision2 Debugger #endif while (1) { #ifdef ISD51 // init ISD51 only when the uVision2 Debugger tries to connect ISDcheck(); // initialize uVision2 Debugger and continue program run #endif i++; } }
More info... The info displayed on the error message window as below: ============================================ ISD51 Monitor Error There was a wrong reply from the target system Please check the following items: - Review the initialization of the serial interface (baudrate) - Make sure the loaded application matches the ROM content ============================================ I copied a wrong code last time. Please check the code below. /*------------------------------------------------------------------------------ TEST.C: ISD51 Demo for Infineon C868 Copyright 2003 Keil Software, Inc. ------------------------------------------------------------------------------*/ #include <intrins.h> #include <stdio.h> #include "ISD51.h" #include "reg515a.h" /* parameters to initialize serial communication */ #define B_38400 0x05 /* 38400 baud */ #define B_19200 0x04 /* 19200 baud */ #define B_9600 0x03 /* 9600 baud */ #define B_4800 0x02 /* 4800 baud */ #define B_2400 0x01 /* 2400 baud */ #define B_1200 0x00 /* 1200 baud */ void Delay(unsigned int i) { unsigned int j; while(i--) { // delay WDT = 1; // reset SWDT = 1; j = 0x200; while (j--); } } void Project_Init(serBaud) { switch ( serBaud ) { /* oscillator frequency = 10 Mhz */ case B_38400: SRELH = 0x03; /* Reloadwert für 38400 Baud */ SRELL = 0xF0; PCON |= 0x80; /* SMOD = 1 */ break; case B_19200: SRELH = 0x03; /* Reloadwert für 19200 Baud */ SRELL = 0xDF; PCON |= 0x80; /* SMOD = 1 */ break; case B_9600: SRELH = 0x03; /* Reloadwert für 9600 Baud */ SRELL = 0xBF; PCON |= 0x80; /* SMOD = 1 */ break; case B_4800: SRELH = 0x03; /* Reloadwert für 4800 Baud */ SRELL = 0x7E; PCON |= 0x80; /* SMOD = 1 */ break; case B_2400: SRELH = 0x02; /* Reloadwert für 2400 Baud */ SRELL = 0xFC; PCON |= 0x80; /* SMOD = 1 */ break; case B_1200: SRELH = 0x01; /* Reloadwert für 1200 Baud */ SRELL = 0xF7; PCON |= 0x80; /* SMOD = 1 */ break; default: return; break; } ADCON0 |= 0x80; /* enable baud rate generator */ SCON = 0x50; /* mode 1: 8-bit UART, enable receiver */ } #if 1 // uncomment this function to verify serial communication /* * Test Function: verify serial communication with HyperTerminal */ void TestSerial (void) { char c = 'A'; TI = 1; while (1) { Delay(200); if (RI) { c = SBUF; RI = 0; } while (!TI); TI = 0; SBUF = c; } } #endif void main (void) { unsigned int i; Project_Init(B_9600); // Initialize Chip and Serial Interface #ifndef ISD51 // init ISD51 only when the uVision2 Debugger tries to connect TestSerial(); #endif #ifdef ISD51 // init ISD51 and start user program until the uVision2 Debugger connects ISDinit (); // initialize uVision2 Debugger and continue program run #endif #if 0 // init ISD51 and wait until the uVision2 Debugger connects ISDwait (); // wait for connection to uVision2 Debugger #endif ES = 1; /* enable serial interrupt IE.ES */ while (1) { #ifdef ISD51 // init ISD51 only when the uVision2 Debugger tries to connect ISDcheck(); // initialize uVision2 Debugger and continue program run Delay(200); #endif i++; } }
Your serial initialization is for the XC868 and not for the C505 device. You need to change the serial initialization.
Can you tell which part or where I need to change the serial initialztion, ISD51.A51 or ISD51.h? Is ISDinit(), ISDcheck()? Thanks.
The manual contains a step by step plan under: http://www.keil.com/support/man/docs/isd51/isd51_sw_config.htm I guess that you are currently on #5 of that list.
I think I did everything using all Keil website info. Below is my updated ISD51.h matching C515C processor. Can you help find out anything wrong in this file? Thanks. Frank //--------------------------------------------------- #define RAMSIZE 0xF8 // default is 0x100 => 256 bytes IDATA RAM #define CMP_START 0x0 // default is 0 #define CMP_END 0x7FFF // default is 64KB (0xFFFF) //------------------------------------------------------------------------------ #ifndef __C51__ /* 8051 SFR Register addresses for on-chip 8051 UART */ sfr SCON = 0x98; sfr SBUF = 0x99; sfr IEN0 = 0xA8; /* SCON Bits */ sbit TI = SCON^1; sbit RI = SCON^0; /* IEN0 Bits */ sbit ES = IEN0^4; CLR_TI MACRO ; Clear Transmit Interrupt Flag CLR TI ; No CPU register may be changed here ENDM SET_TI MACRO ; Set Transmit Interrupt Flag SETB TI ; No CPU register may be changed here ENDM JNB_TI MACRO label ; Jump if Transmit Interrupt Flag not set JNB TI,label ; PSW may be modified without saving it ENDM WR_SBUF MACRO ; Write ACC to SBUF MOV SBUF,A ; ACC and PSW may be modified without saving it ENDM CLR_RI MACRO ; Clear Receiver Interrupt Flag CLR RI ; No CPU register may be changed here ENDM JB_RI MACRO label ; Jump if Receiver Interrupt Flag set JB RI,label ; ACC and PSW may be modified without saving it ENDM JNB_RI MACRO label ; Jump if Receiver Interrupt Flag not set JNB RI,label ; ACC and PSW may be modified without saving it ENDM RD_SBUF MACRO ; Return SBUF in ACC MOV A,SBUF ; ACC and PSW may be modified without saving it ENDM CLR_ES MACRO ; Disable Serial Interrupt CLR ES ; No CPU register may be changed here ENDM SET_ES MACRO ; Enable Serial Interrupt SETB ES ; No CPU register may be changed here ENDM JNB_ES MACRO label ; Jump if Receiver Interrupt Flag not set JNB ES,label ; ACC and PSW may be modified without saving it ENDM SAVE_ES MACRO ; Save Serial Interrupt enable bit to Carry MOV C,ES ; ACC and PSW may be modified without saving it ENDM RESTO_ES MACRO ; Restore Serial Interrupt enable bit from Carry MOV ES,C ; ACC and PSW may be modified without saving it ENDM SINTRVEC EQU 0x23 ; Interrupt Vector Address of UART interrupt #endif //------------------------------------------------------------------------------ // // ISD51 CODE MEMORY ACCESS FUNCTIONS FOR HARDWARE BREAKPOINTS // =========================================================== //
Step "5. Add serial port and baud rate initialization code for the on-chip UART to your C main function." You did not post your C main function. Take a look to "Keil\c51\ISD51\Examples\Generic 8052". TEST.C contains a sample main.
In future posts, you should refer to the file and you place source code source code between <pre></font> and </pre>. For example from TEST.C: void main (void) { unsigned int i; T2CON = 0x34; /* Use Timer 2 as baudrate generator */ #if 0 RCAP2H = 0xFF; RCAP2L = 0xBF; /* 19230 baud @ 20MHz */ #endif RCAP2H = 0xFF; RCAP2L = 0xD9; /* 19230 baud @ 12MHz */ /* 38460 baud @ 24MHz */ SCON = 0x50; /* enable serial uart & receiver */ EA = 1; /* Enable global interrupt flag */
Sorry, I missed also the source code tabs. This is the correct print-out: For example from TEST.C:
void main (void) { unsigned int i; T2CON = 0x34; /* Use Timer 2 as baudrate generator */ #if 0 RCAP2H = 0xFF; RCAP2L = 0xBF; /* 19230 baud @ 20MHz */ #endif RCAP2H = 0xFF; RCAP2L = 0xD9; /* 19230 baud @ 12MHz */ /* 38460 baud @ 24MHz */ SCON = 0x50; /* enable serial uart & receiver */ EA = 1; /* Enable global interrupt flag */
My main() is in below. Please review it and advise me if something is wrong. Thanks. =============================================
void main (void) { unsigned int i; Project_Init(B_9600); // Initialize Chip and Serial Interface #ifndef ISD51 // init ISD51 only when the uVision2 Debugger tries to connect TestSerial(); #endif #ifdef ISD51 // init ISD51 and start user program until the uVision2 Debugger connects ISDinit (); // initialize uVision2 Debugger and continue program run #endif #if 0 // init ISD51 and wait until the uVision2 Debugger connects ISDwait (); // wait for connection to uVision2 Debugger #endif EAL = 1; /* Enable global interrupt flag */ while (1) { #ifdef ISD51 // init ISD51 only when the uVision2 Debugger tries to connect ISDcheck(); // initialize uVision2 Debugger and continue program run Delay(200); #endif i++; } }
Looks fine. Did you already test serial communiation using Hyperterm. See: http://www.keil.com/support/man/docs/isd51/isd51_trouble.htm
Yes, I did using HyperTerminal and Keil simulator. Both work fine.
View all questions in Keil forum