公告

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

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

cross mob
lock attach
Attachments are accessible only for community members.
Translation_Bot
Community Manager
Community Manager
Community Manager

嗨,

我使用的是xmc7200,串口配置和写错了不知道哪里写错了, CAN 不输入中断 CAN 不接收数据。

最好的问候

0 点赞
5 回复数
lock attach
Attachments are accessible only for community members.
Translation_Bot
Community Manager
Community Manager
Community Manager

1:据我了解,此问题与中断配置有关。

2:我给你关于 M7 uart 中断配置的代码片段:

/* Populate configuration structure (code specific for CM4) */
cy_stc_sysint_t uartIntrConfig =
{
    .intrsrc=((NvicMux3_IRQn << 16) | UART3_IRQ),
    .intrPriority = 7,
};
 /* Hook interrupt service routine and enable interrupt */
		(void) Cy_SysInt_Init(&uartIntrConfig, &UART_Isr);
		NVIC_ClearPendingIRQ((IRQn_Type)uartIntrConfig.intrSrc);
		NVIC_EnableIRQ(NvicMux3_IRQn);

例如,我给你一个代码示例,它 CAN 在 rx 中断中获取 rx fifo 值。

void UART_Isr(void)
{
	 if((UART3_HW->INTR_RX_MASKED & SCB_INTR_RX_MASKED_NOT_EMPTY_Msk ) != 0)
	 {
		 UART3_HW->INTR_RX = UART3_HW->INTR_RX & SCB_INTR_RX_NOT_EMPTY_Msk;
		uint32_t rec_data5 = Cy_SCB_UART_Get(SCB3);
		     //	cyhal_uart_putc(&cy_retarget_io_uart_obj,rec_data+1);
		 Cy_SCB_UART_Put(SCB3,rec_data5);
	 }


}

3:相关文档是:

https://www.infineon.com/dgdl/Infineon-AN234226_-_XMC7000_MCU_Usage_of_Interrupts-ApplicationNotes-v...

4:测试代码在附件中。 专注于 Main.c, 我使用低级API,你 CAN 使用我的项目来实现你的功能,然后下一步调试你遇到的问题。

0 点赞
lock attach
Attachments are accessible only for community members.
Translation_Bot
Community Manager
Community Manager
Community Manager

我 CAN没有使用 MTB3.1 导入您的项目,我仍然 CAN不符合您的配置要求。 我 CAN 在使用 MTB3.0 时导入您的项目,但我 CAN运行它并出现错误。

0 点赞
lock attach
Attachments are accessible only for community members.
Translation_Bot
Community Manager
Community Manager
Community Manager

嗨,

我的配置和程序如下,请帮我看看哪里有错误,我的中断功能 CAN 输入。

最好的问候

0 点赞
Translation_Bot
Community Manager
Community Manager
Community Manager

好好,

LinglingG_46_3-1691636937387.png

 

LinglingG_46_1-1691636863308.png

LinglingG_46_0-1691636833367.png

 

LinglingG_46_2-1691636919014.png

/******************************************************************************
* File Name: main.c
*
* Description: This example demonstrates the UART transmit and receive
*              operation using HAL APIs
*
* Related Document: See Readme.md 
*
*******************************************************************************
* Copyright 2019-2023, Cypress Semiconductor Corporation (an Infineon company) or
* an affiliate of Cypress Semiconductor Corporation.  All rights reserved.
*
* This software, including source code, documentation and related
* materials ("Software") is owned by Cypress Semiconductor Corporation
* or one of its affiliates ("Cypress") and is protected by and subject to
* worldwide patent protection (United States and foreign),
* United States copyright laws and international treaty provisions.
* Therefore, you may use this Software only as provided in the license
* agreement accompanying the software package from which you
* obtained this Software ("EULA").
* If no EULA applies, Cypress hereby grants you a personal, non-exclusive,
* non-transferable license to copy, modify, and compile the Software
* source code solely for use in connection with Cypress's
* integrated circuit products.  Any reproduction, modification, translation,
* compilation, or representation of this Software except as specified
* above is prohibited without the express written permission of Cypress.
*
* Disclaimer: THIS SOFTWARE IS PROVIDED AS-IS, WITH NO WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, NONINFRINGEMENT, IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress
* reserves the right to make changes to the Software without notice. Cypress
* does not assume any liability arising out of the application or use of the
* Software or any product or circuit described in the Software. Cypress does
* not authorize its products for use in any products where a malfunction or
* failure of the Cypress product may reasonably be expected to result in
* significant property damage, injury or death ("High Risk Product"). By
* including Cypress's product in a High Risk Product, the manufacturer
* of such system or application assumes all risk of such use and in doing
* so agrees to indemnify Cypress against all liability.
*******************************************************************************/

#include "cyhal.h"
#include "cybsp.h"
#include "cy_retarget_io.h"
#include "cy_pdl.h"


/*******************************************************************************
* Function Name: handle_error
********************************************************************************
* Summary:
* User defined error handling function.
*
* Parameters:
*  void
*
* Return:
*  void
*
*******************************************************************************/
void handle_error(void)
{
     /* Disable all interrupts. */
    __disable_irq();

    CY_ASSERT(0);
}

/*******************************************************************************
* Function Name: main
********************************************************************************
* Summary:
* This is the main function.
* Reads one byte from the serial terminal and echoes back the read byte.
*
* Parameters:
*  void
*
* Return:
*  int
*
*******************************************************************************/
/* Assign UART interrupt number and priority */
#define UART_INTR_NUM        UART3_IRQ
#define UART_INTR_PRIORITY   (7U)

cy_stc_scb_uart_context_t UART0_context;
cy_stc_scb_uart_context_t UART3_context;


/* Populate configuration structure (code specific for CM4) */
cy_stc_sysint_t uartIntrConfig =
{
    .intrsrc=((NvicMux3_IRQn << 16) | UART3_IRQ),
    .intrPriority = 7,
};

void UART_Isr(void)
{
	 if((UART3_HW->INTR_RX_MASKED & SCB_INTR_RX_MASKED_NOT_EMPTY_Msk ) != 0)
	 {
		 UART3_HW->INTR_RX = UART3_HW->INTR_RX & SCB_INTR_RX_NOT_EMPTY_Msk;
		uint32_t rec_data5 = Cy_SCB_UART_Get(SCB3);
		     //	cyhal_uart_putc(&cy_retarget_io_uart_obj,rec_data+1);
		 Cy_SCB_UART_Put(SCB3,rec_data5);
	 }


}

int main(void)
{

	__enable_irq();
    cy_rslt_t result;

    /* Initialize the device and board peripherals */
    result = cybsp_init();
    if (result != CY_RSLT_SUCCESS)
    {
        handle_error();
    }

		/* Initialize SCB for UART operation */
		(void) Cy_SCB_UART_Init(SCB3, &UART3_config, &UART3_context);

		Cy_SCB_UART_Enable(SCB3);

 /* Hook interrupt service routine and enable interrupt */
		(void) Cy_SysInt_Init(&uartIntrConfig, &UART_Isr);
		NVIC_ClearPendingIRQ((IRQn_Type)uartIntrConfig.intrSrc);
		NVIC_EnableIRQ(NvicMux3_IRQn);


		__enable_irq();

	//	Cy_SCB_UART_Put(SCB3,0x64);

    for (;;)
    {

#if 0
    	//Cy_SCB_UART_PutArrayBlocking(SCB0, txBuffer, 3);
    	Cy_SCB_UART_Put(UART0_HW ,0x56);
    	/* Blocking wait for transfer completion */
    	while (!Cy_SCB_UART_IsTxComplete(UART0_HW))
    	{
    	}

#endif

#if 0
    	uint32_t rec_data;
    	if(Cy_SCB_UART_GetNumInRxFifo(SCB0) != 0ul)
    	{
    	rec_data = Cy_SCB_UART_Get(SCB0);
    //	cyhal_uart_putc(&cy_retarget_io_uart_obj,rec_data+1);
    	Cy_SCB_UART_Put(SCB0,rec_data);

    	}

      	uint32_t rec_data2;
        	if(Cy_SCB_UART_GetNumInRxFifo(SCB3) != 0ul)
        	{
        	rec_data2 = Cy_SCB_UART_Get(SCB3);
        //	cyhal_uart_putc(&cy_retarget_io_uart_obj,rec_data+1);
        	Cy_SCB_UART_Put(SCB3,rec_data2);

        	}
#endif
    	//Cy_SysLib_Delay(500);

}
}


/* [] END OF FILE */

 

 

 

谢谢,

玲玲

0 点赞
Translation_Bot
Community Manager
Community Manager
Community Manager

嗨,

串口问题已解决,感谢您的耐心指导。 我还有一个问题要问你,我该怎么处理 ADC 的 DMA 中断? 我想用六个ADC通道的DMA中断读取数据。

最好的问候

0 点赞