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.

Error in Halcogen DCAN code?

Other Parts Discussed in Thread: HALCOGEN

The DCAN module specifies that the user can enter a range of values for the Id: field in the Halcogen GUI. When i enter the value 0-100, the following code gets loaded into the IFxARB register

canREG1->IF1ARB  = (uint32)0x80000000U | (uint32)0x00000000U | (uint32)0x20000000U | (uint32)((uint32)((uint32)0-100U & (uint32)0x000007FFU) << (uint32)18U);

Will the compiler not interpret it as a subtraction operation?? If this wrong,shouldnt Halcogen throw an error message while generating code?

  • Hi Akshay,

    HalCoGen is simply a generator that uses code templates and the GUI to customize the driver code.

    If there is an error you won't catch it until you try to compile the code.

    -Anthony

  • But thats the problem. The entire code compiled and built with no errors.
  • HALCoGen and the compiler support entering a constant expression in the ID field. What you entered is valid, 0-100 was interpreted as 0xFFFFFF9C. (Which is then ANDed with 0x7FF.) I think the problem is that the information block that comes up when you hover over the ID field is misleading. Where it shows "Range 0-." it was meant to indicate the valid range of numbers, but the upper value is missing. It was not meant to imply that you enter a range of numbers here. The way to support a range of IDs is to use the mask bits. I will provide feedback to the HALCoGen team.
  • Thats exactly the reply i was looking for. Because i read the code i was able to spot the fault. A simple error note while generating code in Halcogen when a user enters a wrong range should suffice