Does anyone has ever see the XC161CJ ASC1 working on the KEIl debug window?
I can not "printf" nothing!
here is changed HELLO:
P3 |= 0x0401; /* SET PORT 3.10 OUTPUT LATCH (TXD) */
DP3 |= 0x0401; /* SET PORT 3.10 DIRECTION CONTROL (TXD OUTPUT) */
DP3 &= 0xF7FD; /* RESET PORT 3.11 DIRECTION CONTROL (RXD INPUT) */
ASC1_TIC = 0x80; /* SET TRANSMIT INTERRUPT FLAG */
ASC1_RIC = 0x00; /* DELETE RECEIVE INTERRUPT FLAG */
ASC1_BG = 0x40; /* SET BAUDRATE TO 9600 BAUD @ 20MHz */
ASC1_CON = 0x8011; /* SET SERIAL MODE */
ALTSEL0P3 |= 0x0C01; /* Configure port pins for serial interface 1 */
printf ("Hello World\n");while(1);
and the putchar:
while (!( ASC1_TIC == (ASC1_TIC | 0x80)) );
ASC1_TIC &= ~0x80;
return (ASC1_TBUF = c);
Any comments will be welcomed of course.
the first what is wrong in this code is the pin selection you have taken.
These are the pins for ASC0 (assuming you have no mistake in writing here).
ASC1 pins are 3.0 and 3.1 instead of 3.10 and 3.11.
Second the printf() is build for using ASC0 as standart.
If you run the simulator/debugger you and than stop you will find in disassembly
an assembler jump like this:
ASC1_FDV = 0x00E8;
ASC1_BG = 0x003A;//9600baud with fract. div.
ASC1_CON = 0x0811
ASC1_RXFCON = 0x0102;
ALTSELOP3 |= 0x0001;
P3 |= 0x0001;
DP3 |= 0x0001;
ASC1_TIC_IR = 1; // for printf();
ASC1_CON |= 0x8000; // Enable baudrate gen.
About the pins: It is OK, sorry about the comments but has you probaby noted I have changed the HELLO WORLD example from KEIL.
I believe that the difference between your startup code and my is that you use the fractional divider and I do not.
Nevertheless I copied your code to try it. No success.
About the putchar: Yes I know that the original putchar uses ASC0.
I have changed to :
signed char putchar (signed char c)
//while (!( ASC1_TIC == (ASC1_TIC | 0x80)) );
//ASC1_TIC &= ~0x80;
ASC1_TBUF = c;
Now I see that the ASC1_TBUF=c is executed but I see nothing on the debug serial2 window!
After this the code is blocked on the while (!ASC1_TIC_IR);
I do a test and you are right.
It seems the library was created with different code, since I see in disassembly window ASC0_TIR instead ASC0_TIC_IR.
I had create a own file and translate as object and than link it as I told you,
the routine is called, but with same result:
Blocking in the while-Loop waiting for the flag.
As workaround you may debug with aterminal program ?
This works as you think with a direct write to ASC1_TBUF.
For simulator I can not solve it at the moment. Sorry !
I am back next week. If you have time or solution I will look back for my or your solution.
Otherwise can you directly ask the support, why the disassemblys are different ?
May be we can get the code of the printf/putchar for Xc16x devices to rebuild the library.
sorry that my answer come now and not early. I was on biz trip.
OK - I do contact support directly and was right with thinking about different sources. Now I got a new code and additionally we hav e to use an simulator *.ini file.
I do a test NOW. Than I'll lock back at the site and if you was here please take your e-mail here than I will send the original code from KEIL .
And we will solve this
(I worte directly a terminal program and with this it's working).
I tested the support file and it works!! So you can now use the ASC1 interface with simulator/debugger.
At this time it is only tested for simulator - but that is not a problem since you can use a terminal program for test under hardware conditions, as we discussed.
If you let your mail here - I send you the code and you can adapt as you need.
it is solved now by KEIL's support.
For a more detailed explanation have a look at:
where the first document answers this problem in general and second one is related to use ASc1 directly in µVision2 simulator/debugger.
At this way "many thanks to HS from the KEIL support team for a very excellent well done job"
View all questions in Keil forum