| ??? 09/08/08 03:08 Read: times |
#158036 - Here are defs and original function Responding to: ???'s previous message |
Here are the variable definitions:
#define HC_GAIN_LOW 0x50 //Register 4 CPLD HC mode #define HC_GAIN_HIGH 0xD2 //Register 4 CPLD HC mode Here is the original function:
void SCALED_HC (uchar pot_level)
{
uint HC_Gain_scaled;
uchar HC_Gain;
HC_Gain_scaled = (((HC_GAIN_HIGH - HC_GAIN_LOW) * pot_level)) >> 8; //Average and divide by 256
HC_Gain_scaled += HC_GAIN_LOW;
HC_Gain = HC_Gain_scaled;
Ext_Communication_Write(hcboardw, 0xF0, 0x02, 0x00, 1); //Communicate with CPLD
Wait(t55ms);
Ext_Communication_Write(hcboardw, 0x04, HC_Gain, 0x00, 1); //Set Color Gain
Wait(t55ms);
}
pot_level is passed in from the ADC variable from AD1DAT2 (nxp lpc936) In this function, all data is 8 bits wide. Since I want to change the high and low to INT, that is the issue I'm having question with. |
| Topic | Author | Date |
| Scale offset using ints by byte position location | 01/01/70 00:00 | |
| Does type casting make sense here?... | 01/01/70 00:00 | |
| Show us more......... | 01/01/70 00:00 | |
| Here are defs and original function | 01/01/70 00:00 | |
| ints, at leastin Keil, at 16 bits wide. | 01/01/70 00:00 | |
| Christoph, | 01/01/70 00:00 | |
| That makes things clearer. | 01/01/70 00:00 | |
| A detail | 01/01/70 00:00 | |
| Take a look at the ranges | 01/01/70 00:00 | |
| Brett, that is helpful, I should add.... | 01/01/70 00:00 | |
| No floating-point math required. | 01/01/70 00:00 | |
| Its working but I have a question on theory | 01/01/70 00:00 | |
| Rounding instead of truncate | 01/01/70 00:00 | |
| oh, that is interesting | 01/01/70 00:00 | |
Russ' comment is right, though. | 01/01/70 00:00 |



