Post Go back to editing

BF527, Max1233 and VDK error

Hi

I'm having a problem implementing the Max1233 driver in VDK on the BF527 eval board. It initializes correctly and calls the callback function under the initialization. But after that it comes with a kernel error when I pushes on one of the buttons or the touch screen. It calls the callback function again, but in this function:

// return ADC to interrupt-on-event (standby) mode
if((Result = adi_dev_Control(MAX1233DriverHandle, ADI_DEV_CMD_REGISTER_TABLE_WRITE, (void *)MAX1233_DetectKeyPressAndInterrupt))!= ADI_DEV_RESULT_SUCCESS)

{
     printf("Failed to put MAX1233 back into interrupt mode: 0x%08X\n",Result);
}

it comes with the kernel error. I have created a IVG interrupt in the Kernel tab in visualdsp++ and set it to true at "enabled at boot". If it's false the callback function never gets called after init.

The IVG is EVT_IVG13 and the kernel error is:

Code: kISRError

Error: kAPIUsedfromISR

Value: 0x2000

PC: 0xffa02ff4

Any solution to this problem?

Regards

Martin

  • Hi,

    You can see the list of VDK APIs that can be called from thread/ISR/kernel level in the VDK manual but there are very few things that are allowed in an ISR. If VDK is running with either full instrumentation or error checking enabled and it detects one of these APIs running in an ISR then it raises a KernelPanic and it stops. This seems to be what you are seeing.

    There are some C runtime library functions like printf which use mutexes to ensure that they are thread safe. These functions are not interrupt safe and should not be called from an interrupt. In the VDK case this is likely to result in a KernelPanic.

    Note that in System Services a live callback is equivalent to interrupt level and a deferred callback is equivalent to kernel level. Also note that in Blackfin there is no need to add an interrupt in the VDK kernel tab if you don't want to. A non-VDK C interrupt or SSL interrupt should work without issues.

    Let me know if you have any further questions.

    SFernandez

  • Hi

    Thanks for the good feedback. That really helped me alot, understanding some of the things. I will have a look at the VDK manual one more time, and also try to modify the callback function.

    I wanted the driver to run with deferred callbacks, but when I enables it, the code just loops somewhere inside the adi_dev.c file and therefore the driver never gets initialized. I haven't found a solution to this problem yet, and still don't know exactly where it happens. Any idea what could cause this?

    Regars
    Martin

    Edit

    If I use Live callbacks, the callback function is called at init, but when the program is running in thread level and the keypad is pressed, I can see in GPIO registers that the pins is set to high, but no flag is raised so the callback function is never called.

    Maybe the two errors with deferred and live callbacks has something to do with each other?

  • Hi,

    Unfortunately I am not an expert on System Services so I cannot help you with this. Hopefully one of my colleagues will be able to help you specially if you can add an example that would show the problem that you are seeing. If you don't get a response you can contact our support team who might be able to help you with the specific problem in your application.

    Regards

    SFernandez

  • Hi

    Thanks for your answer. I hope someone else can help me in solving the problem with the deferred callback.

    But it seems that I have solved the problem with the live callback, so I will use that to begin with.

    Regards

    Martin

  • Hi

    How are you initializing the callbacks? With a  VDK application you must use the VDK libssl variant, which is linked in  by default unless you've made a positive action to the contrary. The  callback dispatcher is called from the Kernel level running at IVG14. If  a higher priority interrupt is taking too much time, then the callback  will not be processed. Also, ensure that you have sufficient queue  entries available as posting a callback will fail silently if none are  available and the callback will not be processed.

    Without seeing your code, we can only guess what may  be the cause. As my colleague has suggested, please supply some sample  code via the private support channel, if the above does not help.

    with best regards

    Martin

  • Did the semaphore get incremented? What is the status of that thread when you said it doesnt wake up? You can see all that from VDK Status window.

    Also, you only have VDK_PostSemaphore() inside the activate function. What if you post this from callback, like VDK_ISR_POST_SEMAPHORE_()

    Regards

    Prasanth.

  • Hi

    Thanks for your answer.

    Im initializing the callbacks as in the original example  from ADI. I have build the driver totally from the example as you can see in the attached C file.

    The program now runs with live callbacks, and I have a thread that is pending on the semaphore posted in the activate device function, but when the semaphore is posted from the driver file, the thread never wakes up again. The same error when using flags instead of semaphores. I have given the thread priority 2 (to see if that was the problem).

    Im a little bit lost here

    Regards

    Martin

    Max1233.c.zip
  • Hi

    The posting and pending of semaphores seems to be working now. But theres still a problem...

    The callback function is only called ones and after that if I presses the keypad and then halts the program, I get a Core fault detected error. So it seems that the callback function isn't working correctly.

    I've earlier had problems with this part of the code in the callback function:

    // return ADC to interrupt-on-event (standby) mode
    if((Result = adi_dev_Control(MAX1233DriverHandle, ADI_DEV_CMD_REGISTER_TABLE_WRITE, (void *)MAX1233_DetectKeyPressAndInterrupt))!= ADI_DEV_RESULT_SUCCESS)
    {
         printf("Failed to put MAX1233 back into interrupt mode: 0x%08X\n",Result);
    }

    I will debug a little more and see if I can find a solution.

    Regards

    Martin

  • Okay. It seems to work now. In the callback function it only calls the activate device function and from there im doing all the work with converting and reading from the ADC. My idea is then to create 2 global buffers, one for the keypad and one for the touchscreen. The activate function will then fill the 2 buffers with data and from a thread I will read it out again. The buffers will of course be protected with semaphores to avoid any read/write error.

    Does this sound as a good idea?

  • The problem is now solved and i'm closing the thread. Thanks for all your help!

    Regards

    Martin

Before You Switch


Switching languages will make ADI Explorer unavailable. Resume your session by switching back to English and reopening ADI Explorer.