Hello Friends,
I have to read 16-bit data from Port 0 of LPC2129.But the data is not available on consecutive pins. So I assigned a name to each pin like PDB0. To read all 16 bits into a single byte I wrote the following macro to use in my code:
#define DigitalData1() (PDB0|PDB1<<1|PDB2<<2|PDB3<<3|PDB4<<4|PDB5<<5|PDB6<<6|PDB7<<7|PDB8<<8) #define DigitalData2() (PDB9<<9|PDB10<<10|PDB11<<11|PDB12<<12|PDB13<<13|PDB14<<14|PDB15<<15) #define DigitalData() ( DigitalData2() | DigitalData1())
I use DigitalData() to get the 16 bit word into a local variable like this:
ADC7606DataBuff = DigitalData();
Problem here is, this is eating good amount of time to process.
Can you suggest be what is the best way of coding to handle this kind of issues??
Thanks very much!
Was a bit sad that you managed to get 9 different "ranges". Using the same pins on different order, you could have managed with 5 "ranges".
Number of steps to shift left is:
0: 0 1: 0 2: 0 3: 0 4: 7 5: 7 6: 7 7: 8 8: 8 9: 13 <= should have been swapped with next 10: 11 11: 12 12: 12 13: 16 <= should have been swapped with next 14: 14 15: 15
Alas, having 9 groups means that you need 9 groups of (inputs & mask_x) << shift_x.
My four tables in previous post was to map 32 bits to 32 bits. You only need to map 32 bits into 16 bits, so you could get away with four tables of 256 short each, i.e. 2kB of flash space. That is the fastest way you can merge your port bits.
Hardware was already designed by someone. I am left with no option, expect finding a good way of writing some efficient programs, to reduce system overhead...