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
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!)