We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
iam working with cygnal microcontrollers c8051f124,we are generating our own protocol using pwm . i have actually implemented my project in 2 phases,1in c and another in assembly. in the c file iam doing uart communication . once the programe runs the displays menu on pc in that menu 2 nd option iam writing to code memory.ie i have to enter 10 byte information on the menu and this 10 byte information i have to write it code memory. now iam able to write to code memory only when iam defining the string as unsigned char code test_string[]="1111111"; but i need in this form scanf("%s",test_string); i tried this but test_string shows value 00 when i putted in watch kindly plz help how to use scanf()in this type case waiting for ur valuable information. regards ramesh
The 8051 cannot write to code memory! Having done this in assembler, you should know that MOVC is a read-only instruction! If you really need to modify these strings in code memory, you will have to do it by reprogramming the Flash - you will have to read-up on Cygnal's in-application programming support for that!
hello mr neil, thanks for ur valuable reply , ok i will leave code memory , can i write the above 10 byte information to ram or external memory,bcos my second asm programme reads data that written into memory and converts to the pcm format now i must write 10 byte information to any memory location from the console and reading process i have already implemented. kindly plz look into this matter. how to input 10byte information , is it possible from scanf regards ramesh j
Ramesh, I am not really clear what it is you want to achieve. But if all you want to is to copy a string, you should check whether strcpy() (or one of its siblings) will do what you want. See: http://www.keil.com/support/man/docs/c51/c51_strcpy.htm
hello mr neil,this time iam sending my code so that u can get clear picture of my requirement. sir the flash access function is accessed when user press 2 in the print main menu. now it will ask enter the short message 10 byte information , i nead this topic , next i tried to input a string throgh scanf but its not accepting the value what i entered from the menu. i tried to attach the whole code but its not accepting . REQUIREMENT I WANT TO WRITE 10 BYTE HEX VALUE FROM CONSOLE TO CONTROLLER ///////function ///////// void flash_access(void) { unsigned char xdata *pwrite; // pointer to FLASH used for writes // NOTE: this pointer must be located // in <data> or <idata> space! unsigned char code *pread; // pointer to FLASH used for reads unsigned char code test_string[10]; printf("ENTER THE SHORT MESSAGE 10 byte length"); gets(test_string); scanf("%x",test_string); pread = (unsigned char code *) test_string; EA_save = EA; saveinterrupt status0; EA=0; // disable interrupts (precautionary) SFRPAGE=0X0F; pwrite = 0x1000; // initialize FLASH write pointer CCH0CN=0X00; SFRPAGE=0X0F; PSBANK=0X01; SFRPAGE=0X00; FLSCL |= 0x01; // enable FLASH writes/erases from PSCTL = 0x01; // MOVX writes target FLASH memory while (*pread != '\0') { // copy until NULL is detected *pwrite = *pread; // copy byte pread++; // advance pointers pwrite++; } *pwrite = '\0'; // NULL-terminate string SFRPAGE=0X00; PSCTL = 0x00; // MOVX writes target XRAM FLSCL &= ~0x01; // disable FLASH writes/erases from // user software EA = EA_save; // re-enabl EA=1; // while(1); } // Support Routines //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // print_menu //----------------------------------------------------------------------------- // // This routine uses prints the command menu to the UART. // void print_menu(void) { printf("\n\nROTOR TELEMETRY BASEBAND SYSTEM\n"); printf("---------------------------------------\n"); printf("1. BRIDGE BALANCING\n"); printf("2. FLASH MEMORY(READ/WRITE)\n"); printf("3. SHUNT CALIBRATE\n"); printf("4. LEVEL SHIFTING\n"); printf("5. PGA GAIN ADJUST\n"); printf("6. TEMPERATURE SENSOR ADJUST\n"); printf("7. STORE COEFFICIENTS IN EEPROM\n"); printf("8. PCM FORMAT\n"); }
Please read the instructions at the top of the form about posting code. You need to use the < pre > and < /pre > HTML tags so that it formats properly. (I've put extra spaces so they display - you need to omit the spaces so that they work!)
ur ... bcos ... plz answer: Ramesh, I am not really clear what it is you want That is obvious Erik
hello if any one knows solution plz put a reply. ramesh
if any one knows solution plz put a reply. Oh, sorry, I thought you knew. the spelling is "please" Erik
"if any one knows solution plz put a reply." The solution is for you to look up scanf() in the manual and find out whether it does whatever it is you want it to do. If you then think it can do what you want it to do but you cannot get it to work post the non-working code together with a clear description of: 1) what you expect it to do 2) what it actually does and hopefully someone will be able to help you. Please note that using SMS style abbreviations makes it much harder to understand your english. Stefan
Please note that using SMS style abbreviations makes it much harder to understand your english. Since when is Stupid Monkey $#|+ considered english? Erik
Hello iam performing serial communication using cygnal microcontroller.as soon as i will execute code , the user gets menu as mentioned above.when the user goes to option 2 , ie to perform flash / ram reading and writing ,iwant to give some data from the menu that data will write into ram/flash or any memory area , can u please suggest me how to get the data into any variable . here i used scanf statement to input the data but in keil c the variable is not holding the data what i entered from the menu . only technical comments(solution) are invited Thanking you ramesh
u need 2 lrn 2 use scanf() rite. 4 ur xampl code below, u need 2 use sscanf() insted.
unsigned char code test_string[10]; printf("ENTER THE SHORT MESSAGE 10 byte length"); gets(test_string); scanf("%x",test_string);
erik remember yoou rr in discussion room not in chat room
mr erik i really confused are u a civilized monkey