TSS_Init() freezes while debugging

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

TSS_Init() freezes while debugging

Jump to solution
1,889 Views
michele_novalia
Contributor III

Dear all,

 

I am trying to write my own project with KwikStick K40x256 and referring to the Kwikstik demo software.

 

I have no clue why on demo code the debugger goes on fine, while in my code it freezes on the call to TSS_Init() function.

(Precisely it seems in _mqx_idle_task() on idletask.c ).

 

Did anyone face the same?

Is there any obvious reasons for that?

 

I could have configured TSS in the wrong way, but if that was the case I would have thought that it wouldn't compile/link rather than breaking execution at run time...

 

Any idea is welcome.

Thanks in advance

Mik

 

0 Kudos
1 Solution
1,307 Views
Dekiru
Contributor IV

You did not send the full project so can not help if you have any mistake in header file, linker file...

BTW, I tried your code into the the demo with some "dirty" modification (for building purpose)

It works fine. We can see the DBG message on LCD when touch the button.

 

You can check again:

- Check if the service patch for CW10 was installed or not.

- Seem to have problem with TSS CTS sensing method in CW10. You should try to change in to ATL type instead of CTS (Change TSS_SystemSetup.h: #def TSS_USE_ATL_LOW_LEVEL 1
  #undef TSS_USE_CTS_LOW_LEVEL)

 

Regards

View solution in original post

0 Kudos
10 Replies
1,307 Views
konrada_anton
Contributor III

Do you use the debugger's MQX support? If yes, are there other threads? Often when CodeWarrior reaches my breakpoint in some thread, it shows me what the idle task is doing, and I have to select a different thread in the debug view.

 

Speaking of which, which debugger are you using? What do you mean by "freezing"? Unresponsible debugger UI? What does the disassembly view show?

0 Kudos
1,307 Views
michele_novalia
Contributor III

Hi Konrada,

 

thanks for your message: I will try to answer below, but please keep in mind that I am a newbe and I am not sure about few things you asked...

 

> Do you use the debugger's MQX support?

 

I am not sure: any ovious way to check that?

 

> If yes, are there other threads? Often when CodeWarrior reaches my breakpoint in some thread, it shows me what the idle task is doing, and I have to select a different thread in the debug view.

 

yes I do have other threads

 

> Speaking of which, which debugger are you using?

Sorry I am not sure what you mean:

do you mean connection type? kwikstikk40x256_Int_RAM_Segger J-Link

Doesn't otherwise CW come with gdb by default? I am not sure at all...

 

> What do you mean by "freezing"? Unresponsible debugger UI? What does the disassembly view show?

 

The execution just stops there, becomes unresponsive.

If it helps, I will attach 3 screen shots. The 3rd one shows the 'frozen' state, with the assembly view opened.

 

I suspect I may be doing something stupid with project settings, as the KwikStik demo works when debugging at the same point, i.e.: TSS_Init() returns, while it doesn't happen in my code.

 

Thanks!

Mik

 

0 Kudos
1,307 Views
konrada_anton
Contributor III

Your second picture shows the all-in-one kernel interrupt handler. When you reach that unexpectedly, look at the SCB_ICSR register in the registers view, chapter "System Control Registers". Its lowest 8 bits, called VECTACTIVE, tell you the exception number that the processor is trying to handle. If it contains 3, i.e. Hard Fault, then you may have accessed an invalid address or accessed a hardware component which is getting no clock (it's easy to forget the SIM_SCGCx registers). If it contains something above 15, it's an IRQ, worth looking up in the Reference Manual of your processor.

 

If it's a Hard Fault, I recommend stepping through the init function in instruction-stepping mode (a context-menu option on thread objects in the Debug view) and checking which instruction sets off the Hard Fault.

 

(BTW: I asked what debugger etc. because some people use IAR and some CodeWarrior)

 

HTH,

KA

0 Kudos
1,307 Views
michele_novalia
Contributor III

Hello KA,

 

thanks for your suggestion.

Honestly I didn't think I should had hadle registers directly in order to use TSS... I am a bit shocked I must admit.

I will try to understand more reading the chapter you suggested.

 

However I suspect it may be related to problems I am reporting in this other thread:
https://community.freescale.com/message/94524#94524

 

Thanks,
Mik

0 Kudos
1,307 Views
Dekiru
Contributor IV

Hi dev,

 

Some hints that you can check:

- Be sure to to include clock and port setting like that in _Electrodes_Init function.

- I suggest to keep your TSS_SystemSetup.h file the same with file in demo project while debugging. It may not match with your harware configuration but can help to isolate the issue

- Be sure to have callback functions like TSS_fOnFault and TSS1_fCallBack0 that are defined in TSS_SystemSetup.h. Put breakpoint in that functions to see if it come there... 

 

Regards

0 Kudos
1,307 Views
michele_novalia
Contributor III

Hi Dekiru,

 

thanks for your suggestions.

 

> Be sure to to include clock and port setting like that in _Electrodes_Init function.

 

Do you mean additional settings to these in _Electrodes_Init function?

 

 

>  I suggest to keep your TSS_SystemSetup.h file the same with file in demo project while debugging. It may not match with your harware configuration but can help to isolate the issue

 

I did drag and paste the one used in KwikStik demo, which uses my hardware

 

 

>  Be sure to have callback functions like TSS_fOnFault and TSS1_fCallBack0 that are defined in TSS_SystemSetup.h. Put breakpoint in that functions to see if it come there... 

 

Unfortunately it doesn't go there. It blocks inside the while loop of: 

void _mqx_idle_task ()

 

It's quite frustrating I thought that having capacitive touch would be kind of straight away to implement.

(I wonder what could happen with more difficult stuff!)

 

thanks for your help

0 Kudos
1,307 Views
Dekiru
Contributor IV

Hi,

 

For setting, I mean the code that has been there in _Electrode_Init function of the demo.

/**
  Needed for TSS
  */
  SIM_SCGC6 |= SIM_SCGC6_FTM1_MASK;
 
  _GPIO_Init(PORTA,4); 
  _GPIO_Init(PORTA,24);
  _GPIO_Init(PORTA,25);
  _GPIO_Init(PORTA,26);
  _GPIO_Init(PORTA,27);         
  _GPIO_Init(PORTB,0);

 

I don't have any other idea if you don't miss this thing but it is still fail.

I think it might be better to create a simple app with TSS and GPIO first, then add other stub into it later.

We may be able to help to debug if you post that kind of simple app here.

 

Regards

 

0 Kudos
1,307 Views
michele_novalia
Contributor III

Hi Dekiru,

 

first of all, thanks for your patience.

 

My code is really simple:

tss is the same of the KwikStick demo code, and the same for drivers directory (therefore including _Electrode_Init function).

 

My Main file is pretty dummy and it follows.

 

Thanks for your help

Mik

 

 

/****************************************************************************
*
*   This file contains MQX only stationery code.
*
****************************************************************************/
#include "main.h"
#include "TSS_API.h"
#include "Driver_SLCD.h"

#include "Driver_Electrodes.h"


#if !BSPCFG_ENABLE_IO_SUBSYSTEM
#error This application requires BSPCFG_ENABLE_IO_SUBSYSTEM defined non-zero in user_config.h. Please recompile BSP with this option.
#endif


#ifndef BSP_DEFAULT_IO_CHANNEL_DEFINED
#error This application requires BSP_DEFAULT_IO_CHANNEL to be not NULL. Please set corresponding BSPCFG_ENABLE_TTYx to non-zero in user_config.h and recompile BSP with this option.
#endif

const STRING HELLO = "HELLO";
const STRING INITIALIZING = "INIT";
const STRING DBG = "DBG";



TASK_TEMPLATE_STRUCT MQX_template_list[] =
{
/*  Task number, Entry point,     Stack, Pri, String,     Auto? */
   {MAIN_TASK,   Main_task,       1500,  9,   "main",        MQX_AUTO_START_TASK},
   {0,           0,               0,     0,   0,          0,                 }
};

void SystemInit();
void _MainMenu_Electrode_Check();


U08 OptionIndex = 0;
S16 MarqueePosition = 256;
BOOL isMarqueeInitialDelay = TRUE;
BOOL isLoopComplete = FALSE;

/*TASK*-----------------------------------------------------
*
* Task Name    : Main_task
* Comments     :
*    This task prints " Hello World "
*
*END*-----------------------------------------------------*/

void Main_task(uint_32 initial_data)
{
    unsigned int counter = 0;
    static StateMachine SM = INIT;
   printf("\n Hello World \n");

  
   //Initialize the Segment LCD
   _SLCDModule_Init();
    _SLCDMoudle_TurnOffAllSegments();
    _SLCDModule_PrintScrolling(HELLO);
    _time_delay(500);
   
    while ( SM != OFF )
    {
        switch (SM)
        {
            case INIT:
                _SLCDModule_PrintScrolling(INITIALIZING);
                SystemInit();
                SM = MAIN;
                break;
               
            case MAIN:
                _SLCDModule_PrintScrolling(HELLO);
                SM = ELECTRODE_CHECK;
                break;
               
            case ELECTRODE_CHECK:
                _MainMenu_Electrode_Check();
                break;
               
            default:
                break;
        }
       
    }

   _mqx_exit(0);
}


/*
 * SystemInit: Initialises the system
 */

void SystemInit()
{
//    _SLCDModule_PrintScrolling(DBG);
   
    //Turn on FSL icon on segment LCD
    _SLCDModule_TurnOnFreescaleSign();
   
    //Initailze the Touch Sense Software
    _Electrodes_Init();
    TSS_KeypadConfig(cKey0.ControlId,Keypad_MaxTouches_Register,1);
    TSS_SetSystemConfig(System_ElectrodeEnablers_Register,0x33); //Disables E3 & E4
   
}


/**
  Function Name    : _MainMenu_Electrode_Check
  Engineer      : Manglio González Carrasco
  Date          : 05/01/2011

  Parameters    : Nothing
  Returns       : Nothing
  Notes         : This function is used to check the current status of the electrodes and to continuously display
                  the marquee of the current application. if a touch event occurs it sets the state machine to jump
                  to the selected application.
*/
void _MainMenu_Electrode_Check(void)
{   
  static U08 MarqueeDelay = 0x9;
  _Electrodes_Check();

  //TODO:
  // incomplete code, but it never comes in here....
 
  if ((ElectrodeFlags & TSS_ELECTRODE_4) || (ElectrodeFlags & TSS_ELECTRODE_5))
  {
    switch (OptionIndex)
    {
    default:
        _SLCDModule_PrintScrolling(DBG);
        break;
    }
  }
 
  if (isLoopComplete == TRUE)
  {
    isMarqueeInitialDelay = TRUE;
    isLoopComplete = FALSE;
  }
}

/* EOF */

0 Kudos
1,308 Views
Dekiru
Contributor IV

You did not send the full project so can not help if you have any mistake in header file, linker file...

BTW, I tried your code into the the demo with some "dirty" modification (for building purpose)

It works fine. We can see the DBG message on LCD when touch the button.

 

You can check again:

- Check if the service patch for CW10 was installed or not.

- Seem to have problem with TSS CTS sensing method in CW10. You should try to change in to ATL type instead of CTS (Change TSS_SystemSetup.h: #def TSS_USE_ATL_LOW_LEVEL 1
  #undef TSS_USE_CTS_LOW_LEVEL)

 

Regards

0 Kudos
1,307 Views
michele_novalia
Contributor III

Dekiru,

 

you made my day!

This was the problem:

 

> Seem to have problem with TSS CTS sensing method in CW10.

> You should try to change in to ATL type instead of CTS (Change TSS_SystemSetup.h: #def TSS_USE_ATL_LOW_LEVEL 1
  #undef TSS_USE_CTS_LOW_LEVEL)

 

Thank you so much!

Please remember me I owe you a beer!

 

Thanks a lot!

Mik

0 Kudos