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.
As a fairly new student in C I am having diffictly with arrays. I have a string of numbers that I am tring to split up into smaller strings to convert them to integers. I have made the code as basic as possible but still get the errors.
#include <stdio.h> #include <stdlib.h> #include <reg52.h> xdata char Temperatures1[9]; xdata char Temperatures2[12]; xdata char Temperatures3[9]; void main(void) { char a[36] = "<<123456789012345678901234567890>>"; int s; SCON = 0x52; TMOD = 0x20; TCON = 0x69; TH1 = 0xF5; for(s=0; s < 9; s++) { Temperatures1[s] = a[s+2]; } for(s=0; s < 12; s++) { Temperatures2[s] = a[s+11]; } for(s=0; s < 9; s++) { Temperatures3[s] = a[s+23]; } printf("Temperatures1: %s\n", Temperatures1); printf("Temperatures2: %s\n", Temperatures2); printf("Temperatures3: %s\n", Temperatures3); }
Can we create our own segments in C51/L51? In GCC and Diab DCC we can create a segment and then tell the compiler to place certain objects in these segments. These segments are unknown to the default C run-time and thus are left alone, e.g. not cleared and not initialized with compile time values. For example, for NVRAM I'd place all my NVRAM objects in a segment called .nvRam and create in a linker control file. Then, at the definition of my NVRAM objects I'd just indicate that the compiler should put these objects in the .nvRam segment. Hmm... maybe _at_ would take care of this just fine. Same net affect I guess. Regards, - Mark