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?
As long as you don't show how those variables are defined, nobody can help you meaningfully.
Better still, show an actual, complete source code example.
Before posting code, be sure to read the instructions for posting code: http://www.keil.com/forum/tips.asp
Be sure to post the actual code that you compile & test: use copy-and-pase; do not manually re-type it into your post.
Also show what output is produced - just saying "garbage" is not helpful.
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; }
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.
View all questions in Keil forum