This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

XC161CJ ASC1

Hi,

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.

Thanks,
joao

Parents
  • Hi Joao,

    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:

     JNB ASC0_TIR,0xC00428 
    .
    What indicates the putchar uses the ASC0.
    You have to modify the putchar() function
    in this way that you replace the ASC0 with the entries for ASC1.
    The source you can find in LIB-directory.
    Than build an OBJ-file and linke this
    to your project instead the original.

    May be you only take the wrong pin selection,
    since I not proved your putchar function.

    My init code look 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.
    


    Hope this helps
    Stefan

Reply
  • Hi Joao,

    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:

     JNB ASC0_TIR,0xC00428 
    .
    What indicates the putchar uses the ASC0.
    You have to modify the putchar() function
    in this way that you replace the ASC0 with the entries for ASC1.
    The source you can find in LIB-directory.
    Than build an OBJ-file and linke this
    to your project instead the original.

    May be you only take the wrong pin selection,
    since I not proved your putchar function.

    My init code look 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.
    


    Hope this helps
    Stefan

Children