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

based use xdate (ADUC 812)

i'm using AnalogDevicesuC 812.
If i'm don't mistake, I have an external memory on this ev. board.
I try do based use in this xdata but don't succsess.

memcpy (data_buffer, "DATA Buffer....", sizeof (data_buffer));
memcpy (xdata_buffer, "XDATA Buffer....", sizeof (xdata_buffer));
printf(data_buffer);
printf(xdata_buffer);

data_buffer has been ok, but xdata_buffer printed garbage...

maybe I need do some change in my ADuC812 board or do a change in keil propities?

Parents Reply Children
  • Does your board and/or processor require the XDATA to be enabled before it can be used?

    Are you sure that your board has XDATA at address 0x0200?

    What happens if you remove the _at_ 0x0200 ?

    Don't use TABs to lay-out your code - use only spaces.

  • This is the code now:

    /************* Header files ****************************************************/
    #include "ADuC812.H" // Header file for the ADuC812 MCU
    #include <STDIO.H>     // Standard I/O header file
    #include <STRING.H>
    
    
    sbit  P3_4      = 0xB4;
    unsigned char xdata xdata_buffer [16];
    unsigned char data  data_buffer  [16] _at_ 0x60;
    int num;
    unsigned char interupt1 = 0;
    
    #define LED     P3_4 // LED Output
    
    void initialize_system (void);
    
    void ex0_isr (void) interrupt 0 {
            interupt1 = 1;
    }
    
    /************* MAIN C Function *************************************************/
    void main (void)
    {
            //flash_erase_all ();
            initialize_system(); // apply start setting for connect with HyperTerminal
    
            num = 3;
            memcpy (data_buffer, "DATA Buffer....", sizeof (data_buffer));
            memcpy (xdata_buffer, "XDATA Buffer....", sizeof (xdata_buffer));
            while (1)
            {
                    if(interupt1==1){
    
                            printf("a");
                            num++;
                            printf("%d", num);
                            if(num%2==0){
                                    LED ^= -1;
                            }
    
                            interupt1=0;
                            printf(data_buffer);
                            printf(xdata_buffer);
                    }
    
            }
    }
    
    
    void initialize_system (void)
    {
             // Initialize the serial port (9600, 8, N, 1) [see page 32 of data sheet]
            PCON &= 0x7F; // Clear bit 7 of the PCON register (SMOD1 = 0)
            SCON = 0x50;  // 0101,0000 (Mode 1 and RxD enable)
            TMOD |= 0x20; // Timer #1 in autoreload 8 bit mode
            TCON = 0x40;  // Set Timer #1 to run mode
            TH1 = 0xFA;       // Baud rate is determined by
     // Timer #1 overflow rate
     // Baud Rate = (Fcpu / 384) / (256 - TH1)
     // Fcpu = 11.0592 MHz
     // TH1 = FD = 253 -> Baud Rate = 9600
     // TH1 = FA = 250 -> Baud Rate = 4800
            TR1 = 1; // Turn on Timer 1
            TI = 1;  // Set UART to send first char
    
    
            IT0 = 1; // Configure interrupt 0 for falling edge on /INT0 (P3.2)
            EX0 = 1; // Enable EX0 Interrupt
            EA = 1;  // Enable Global Interrupt Flag
    
            return;
    }
    
    
    

  • and this is the full output for 2 external interupts:

    a4DATA Buffer....@ABCDFgHIJk
    X'!"#$&'()*+,-./p123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_'
    abcdefghijklmnopqrstuvwxyz{|}~à‚ƒ„…†‡ˆ‰Š‹ŒŽ''""•–—˜™š›œžŸà¡¢£¤¥¦ç詪«¬­®¯ð
    ±²³'µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ@
    GÈ
    
    PØßà!"#$&g()*+,-./0123456wø9:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_'
    abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡È‰Š‹ŒŽ''""•–—˜™š›œžŸà¡¢£¤¥¦§è©ª«¬­®¯°
    ±²³'µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ@
    ABCDFGHIJK
    
    PØà!"#$&'è)*+,-./p123456789:;<=>@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_'
    abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡È‰Š‹ŒŽÐ''""•–—˜™š›œžßà¡¢£¤¥¦§è©ª«¬­®¯ð
    ±²³'µ¶·ø¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿa
    5DATA Buffer....@ABCDFgHIJk
    X'!"#$&'()*+,-./p123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_'
    abcdefghijklmnopqrstuvwxyz{|}~à‚ƒ„…†‡ˆ‰Š‹ŒŽ''""•–—˜™š›œžŸà¡¢£¤¥¦ç詪«¬­®¯ð
    ±²³'µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòó

  • The core problem here is a buffer overrun. Check how much memory your strings actually consume, and how big your arrays are. Your string written to xdata lacks the terminating '\0'. Bad mojo.

    And two more things: don't use printf() where fputs() would suffice, and absolutely don't use it without a format string.

  • I don't know if I need to change something in my ADUC board to enable the XDATA...

    Then what the heck do you think you're doing writing code using xdata memory without having figured that out first?

    It's quite probable that you don't have active xdata memory --- the pattern of your output is quite typical for the virtual contents of external memory that's not actually there: the data bytes are the low-byte of their own address, since that was the last thing written to the shared A/D bus lines when the CPU tried to read them.