This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DRV8301-69M-KIT: Serial port data translation

Part Number: DRV8301-69M-KIT

I have an A/D operation that reads a value so it is a IQ12 number. I convert it to IQ24 using the TI library so now I have a long number and in the CCS I can cast it to a Q-24 number within CCS and it is correct. Now I want to send that data out the serial port. I tried to do a simple break into an array of bytes. I tried to declare a byte my_var[4] and then using shift operations break up the number. However byte is not defined in the motor ware it seems. So how do I go about getting these values out via the serial port?

  • To add some more detail to help see where I am wrong. I am very new to working with IQ math. The result of the A/D operation and the adjustment to Q24 shows a value of 15654912 and if I right click in CCS and convert to Q-24 then it reads approximately 0.933. If you divide 15654912 by 16777216 this appears about right. If you convert what seems to be the decimal value of 15654912 to hex it is 0xEEE000. This seems correct since it is 3 bytes and Q24 should be 3 bytes (I think). I tried to build and array of char[4] by doing this. 

    myarray[0] = value >> 24

    myarray[1] = value >> 16

    myarray[2] = value >> 8

    myarray[3] = value

    I expected 

    myarray[0] =0x00 (0)

    myarray[1] = 0xEE (238)

    myarray[2] = 0xE0 (224)

    myarray[3] = 0x00 (0)

    Am I missing something?

    Thanks

  • There is no 8-bit byte type on the C28x--a char is 16 bits. Does that explain the issue? What are the actual values you're seeing in myarray? If you mask off the upper 8 bits as you write to myarray, does it give you the expected values or does there appear to be something else going on?

    Whitney

  • Well duh - I missed that sorry! On this same subject some of the numbers I want to put on the serial link it would be nice to use the Q24 version such as in this case approximately 0.93xxx. Is there some available function to serialize this to a series of characters that I can send out the serial link?

  • If it was floating point, I'd probably use sprintf() to get nice printable characters, although I'm not sure about Q24 numbers unfortunately. I guess if you're just logging a bunch of raw data to a file you could do some post processing to convert them.

    Whitney