AurixTC3xx CCU6_ADC中断采样无法打印

公告

大中华汽车电子生态圈社区并入开发者社区- 更多资讯点击此

Tip / 登入 to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
JunePan
Level 1
Level 1
5 replies posted 5 sign-ins First like given

AurixTC3xx CCU6_ADC中断采样无法触发,使用的是官方的CCU6_ADC 代码CCU6_ADC_1_KIT_TC397_TFT,CCU6_ADC.c里面替换了一个串口的打印,AsclinShellInterface_init();然后再启用定时器发现没有办法产生中断,把代码里的void ISR_ADC_result(void)
{
/* Get the result from the EVADC result register and print it using the UART communication */
Ifx_EVADC_G_RES conversionResult = IfxEvadc_Adc_getResult(&g_adcChannel);
IfxStdIf_DPipe_print(&g_stdInterface, "ADC Sample: %d\r\n", conversionResult.B.RESULT);
}

换成了

void ISR_ADC_result(void)
{
/* Get the result from the EVADC result register and print it using the UART communication */
Ifx_EVADC_G_RES conversionResult = IfxEvadc_Adc_getResult(&g_adcChannel);
DbgPrintf("ADC Sample: %lu\r\n",conversionResult.B.RESULT);

}

#TC39x @infineon @Infineon1 

0 点赞
1 解答
Kunqiao_L
Moderator
Moderator
Moderator
First comment on blog First like given 25 likes received

Hi JunePan,

Thanks for your inquiry. Firstly, have you tried to run successfully on the non-change example code? Secondly, could you show me what is the definition or source code of the DbgPrintf and AsclinShellInterface_init? I didn't locate them in the code example

 

 

在原帖中查看解决方案

0 点赞
11 回复数
Kunqiao_L
Moderator
Moderator
Moderator
First comment on blog First like given 25 likes received

Hi JunePan,

Thanks for your inquiry. Firstly, have you tried to run successfully on the non-change example code? Secondly, could you show me what is the definition or source code of the DbgPrintf and AsclinShellInterface_init? I didn't locate them in the code example

 

 

0 点赞
Kunqiao_L
Moderator
Moderator
Moderator
First comment on blog First like given 25 likes received

Hi JunePan,

Are you still having the issue about the ADC interrupt? 

lock attach
Attachments are accessible only for community members.
JunePan
Level 1
Level 1
5 replies posted 5 sign-ins First like given

Hi Likeun,

The problem has been solved, I need to add a line of code when initializing the interrupt - IfxCpu_Irq_ installInterruptHandler (SCUERU_Int0_Handler, ISR_PRIORITY_SCUERU_INT0);
May I ask why the sample code is not needed? Is there anything special about this function?

0 点赞
Kunqiao_L
Moderator
Moderator
Moderator
First comment on blog First like given 25 likes received

Hi JunePan,

As far as I checked, the function IfxCpu_Irq_installInterruptHandler(ISR_ADC_result, ISR_PRIORITY_ADC) and  IFX_INTERRUPT(ISR_ADC_result, 0, ISR_PRIORITY_ADC) are the same.

IFX_likunqiao_0-1692695040007.png

In order to duplicate this, please provide me the DbgPrintf function that I could try from my side. BTW,  are you sure the only difference between example code and yours is this printing function? Also, one more thing you could see is that try to find the interrupt vector of this isr, and check its function address whether it is the same as ISR_ADC_resultThanks

0 点赞
JunePan
Level 1
Level 1
5 replies posted 5 sign-ins First like given

Hi Likun,

I'm not sure if it's because of DbgPrintf, but only DbgPrintf was changed when asking the question. Others are consistent with the example code and cannot enter the interrupt. Maybe it's because of changes in the underlying code or version changes?

The DbgPrinf function is defined as follow:

void DbgPrintf(const char *fmt, ...)
{
char strings[MAX_DBG_BUFFER_SIZE];
 
memset(strings,0x00,sizeof(strings));
 
va_list args;
va_start(args, fmt);
vsprintf(strings, fmt, args);
va_end(args);
 
Ifx_Console_print("%s", strings);
}
 
IFX_INTERRUPT is defined as follow:

#define IFX_INTERRUPT(isr, vectabNum, prio)

/** \} */
#error "Compiler unsupported"
#endif

 

0 点赞
Kunqiao_L
Moderator
Moderator
Moderator
First comment on blog First like given 25 likes received

What toolchain are you using? Is it Aurix development Studio? If that so, you are using Tasking compiler and your#define IFX_INTERRUPT(isr, vectabNum, prio) should be defined at my previous screen shot place. 

IFX_likunqiao_0-1692697095230.png

Also, please check your sensor and serial port initialization code, it might have some isr register which overwrite the ADC interrupt service routine. Make sure all interrupts have different priority value

0 点赞
lock attach
Attachments are accessible only for community members.
JunePan
Level 1
Level 1
5 replies posted 5 sign-ins First like given

Hi Likun,

The toolchain I use is Hightec, the IDE uses BIFACE,Priority confirmation does not conflict.

Thanks for your answer.

JunePan_0-1692698397270.png

 

#if defined(__DCC__)
#include "CompilerDcc.h"

#elif defined(__HIGHTEC__)
#include "CompilerGnuc.h"

#elif defined(__TASKING__)
#include "CompilerTasking.h"

#elif defined(__ghs__)
#include "CompilerGhs.h"

#elif defined(__MSVC__)
#include "CompilerMsvc.h"

#else

/** \addtogroup IfxLld_Cpu_Std_Interrupt
* \{ */
/** \brief Macro to define Interrupt Service Routine.
* This macro makes following definitions:\n
* 1) Define linker section as .intvec_tc<vector number>_<interrupt priority>.\n
* 2) define compiler specific attribute for the interrupt functions.\n
* 3) define the Interrupt service routine as Isr function.\n
* To get details about usage of this macro, refer \ref IfxLld_Cpu_Irq_Usage
*
* \param isr Name of the Isr function.
* \param vectabNum Vector table number.
* \param prio Interrupt priority. Refer Usage of Interrupt Macro for more details.
*/
#define IFX_INTERRUPT(isr, vectabNum, prio)

0 点赞
Kunqiao_L
Moderator
Moderator
Moderator
First comment on blog First like given 25 likes received

Hi JunePan,

Regarding usage of the code example, we recommended use Aurix Development Studio(ADS) + Tasking compiler toolchain to try. Like BIFACE + Hightec toolchain, it might have some porting and integration issue have to fix on the user side. 

One thing, comes to my mind is that how do you initialize your interrupt vector table? There are two ways of that Hardware managed interrupts and Software managed interrupts, defined by #ifdefined(IFX_USE_SW_MANAGED_INT). They have two different behaviors and way to register the isr based on the priority.  Our code example on ADS use hardware managed way.  See this reference link below:

https://www.cnblogs.com/uestcliming666/p/12308428.html

 

Also, you could debug it by checking BIV register(mine is 0x 802F E000), the original ISR_ADC_result use priority 4, which means there are 4*32byte = 128byte offset (0x80). The corresponding isr instructions should place to 0x802F E080. By reading the disassembly code, it would load and jump to 0x8000 0336 address which is  ISR_ADC_result function. You could try to see if your vector table could jump to the correct position as I have. 

IFX_likunqiao_0-1692772586976.png

Just let me know the result. I think it might explain why you need to use extra function here: IfxCpu_Irq_installInterruptHandler

JunePan
Level 1
Level 1
5 replies posted 5 sign-ins First like given

Hi Likun,

The BIV register I found is as follows

/** \brief FE20, CPUx Base Interrupt Vector Table Pointer */
#define CPU0_BIV /*lint --e(923, 9078)*/ (*(volatile Ifx_CPU_BIV*)0xF881FE20u)

 

.string "ISR_ADC_result"
.byte 0x1
.byte 0xca
.byte 0x1
.uaword .LFB684
.uaword .LFE684
.byte 0x1
.byte 0x9c
.byte 0x1
.uaword 0x124e7
.uleb128 0x3b
您图片里的部分无法找到,中断向量表IfxCpu_Irq_intVecTable0无法跳转

IFX_INTERRUPT_INTERNAL(IfxCpu_Irq_intVecTable0, 0, 255)
{
Ifx_CPU_ICR icr;

icr.U = __mfcr(CPU_ICR); /*Fetch the ICR value */

/*Call the ISR */
if(IfxCpu_Irq_swIntVector0[icr.B.CCPN])
{
IfxCpu_Irq_swIntVector0[icr.B.CCPN]();
}
else
{
IFX_CFG_CPU_IRQ_DEBUG;
}
}

0 点赞
Kunqiao_L
Moderator
Moderator
Moderator
First comment on blog First like given 25 likes received

Hi JunePan,

Please try to see BIV register value in the debugger, this CPU0_BIV is the address not the value. Also check if you defines IFX_USE_SW_MANAGED_INT, that may cause you use Software managed interrupts.

Thanks

0 点赞
JunePan
Level 1
Level 1
5 replies posted 5 sign-ins First like given

Hi Likun,
Sorry, I remember that I also added some sensor initialization part and serial port initialization part. This runs without problem in other functions.

0 点赞