Hi
I work on a TMS570LS31USB kit and I want to send CAN data to the computer
I already made CANcommunication example which is in the halcogen>help>example file and it Works.But at this program which I write below when I want to send ADC data it gives error about the value.How can I convert the value which CAN communication want.
CAN communication gives maximum 8 bit but my ADC value is 12 bit.How can I convert it?
Thanks
double x;
double y;
adcData_t adc_data; //ADC Data Structure
adcData_t *adc_data_ptr = &adc_data; //ADC Data Pointer
unsigned int NumberOfChars, value; //Declare variables
adcInit(); //Initializes the ADC module
hetInit();
canInit();
while(1) // Loop to acquire and send ADC sample data via the SCI (UART)
{
adcStartConversion(adcREG1, 1U); //Start ADC conversion
while(!adcIsConversionComplete(adcREG1, 1U)); //Wait for ADC conversion
adcGetData(adcREG1, 1U, adc_data_ptr); //Store conversion into ADC pointer
value = (unsigned int)adc_data_ptr->value;
NumberOfChars = ltoa(value,(char *)command);
x=value;//* ADC değeri ata *//
canTransmit(canREG1, canMESSAGE_BOX1, x);
if(x<4096)
{
y=100-(100*x/4096);
pwmSetDuty(hetRAM1, pwm0, y);
}
else
{
pwmSetDuty(hetRAM1, pwm0, 0);
}