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.
Hello Sir,
I am using LPC2368 controller in my project My project have some 1-bit flag as shown in following code flag number 1 to 22 working properly means writing 0 or 1 has affect on that. But when I write 1 value to flag there is no change in flag.when i declare flag number ,23 ,24 ,25 of 1 byte seperately instead of using in this structure they are working properly i just want to confirm that is there is any bit addressable area in LPC2368 I checked the memory map of my project i sae that genflag structure is stored at 0x40000128 address and it is taking 12 byte why it is taking 12 byte?
struct flag{ unsigned fill_start:1; //1 unsigned pow_pap_feed:1; //2 unsigned fl_print_start:1; unsigned fl_stop_print:1; unsigned fl_pap_sensor:1; unsigned fl_platen_out:1; unsigned fl_cutr_acc_ON:1; unsigned fl_const_speed:1; unsigned fl_line_print:1; unsigned fl_start_print:1; unsigned fl_pf_only:1; unsigned fl_start:1; unsigned fl_mt_accer:1; unsigned fl_mt_deaccer:1; unsigned fl_phase_rev:1; unsigned fl_half_cut:1; unsigned fl_home_position; unsigned paperout:2; unsigned fl_tempabove_80:1; unsigned fl_recive_enable:1; unsigned fl_init:1; unsigned fl_stop_receive:1; //22 unsigned fl_ESC_command:1;//23 unsigned fl_GS_command:1;//24 unsigned receive_cmd_arg:1;//25 unsigned wait4chartimeout:1;//26 }genflag;
Thanks & Regards Rohit
No, the LPC23xx chips don't have any bit-addressable memory, and I'm not sure why you think it should have.
Look at Cortex chips if you want a processor that have a special hardware solution for overlaying bitmaps on top of integers. The ARM core don't have special bitmap instructions so the solution used is to have a large array of integers overlapping so each integer in the array maps to a single bit of an integer at a different memory region. That allows the processor core to perform register-wide reads/writes when updating individual bits - all handled by the memory controller logic.
You have 16 1-bit variables followed by the four byte large unsigned fl_home_position;
Because of align, you will get 2 byte padding so fl_home_position gets 4-byte-aligned.
So 2 bytes of bit-data, 2 bytes fillers, 4 bytes fl_home_position. That makes 8 bytes.
Then you continue with 10 more bits of data. Now you have reached 10 bytes.
Because the structure internally requires 4-byte align, the compiler will make the struct padded to be a multiple of four bytes large. This is required in case you have an array of this struct. So the struct will consume 2 bytes more with padding.
So in total - 12 bytes consumed.
If your 32-bit variable fl_home_position is placed first, you would get an 8 byte large struct since your 16+10 = 26 bits of bit-addressable fields can fit in four bytes.
Thanks Sir for your kind support
rohit