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

PSoC™ 6 Forum Discussions

LeiS_01
Employee
Employee
First like given First question asked First reply posted

Hello,

I am trying to study the Systick and UART on PSoC 6 BLE Pioneer Kit. Systick generate 1ms interrupt and blink GPIO as 500ms cycle in the main loop. Uart work as 115200 baud rate, use Rx Interrupt to receive a Byte, send out the received data in the main loop. Source code as below.

  1. It works well when the systick and UART both run on the Cortex-M4 core. LED blink as 500ms cycyle, Tera Term can receive the TX data accordingly. Cortex-M0+ will go to deepsleep after start the M4 core started.
  2. When I am trying to run the LED blink function with Systick on cortex-M0+ core, it seems the LED blink works well, but UART loopback function at Cortex-M4 core have problems.

Would you please help for this case?

I can upload my test project if necessary.

Thank you!

Best regards,

Lei

#include "project.h"

uint8_t UartRxFlag = 0;

uint8_t UartRxDat = 0;

uint32_t SysTickCnt = 0;

void ISR_UART(void)

{

/* Check for "RX fifo not empty interrupt" */

    if((UART_HW->INTR_RX_MASKED & SCB_INTR_RX_MASKED_NOT_EMPTY_Msk ) != 0)

    {

/* Clear UART "RX fifo not empty interrupt" */

UART_HW->INTR_RX = UART_HW->INTR_RX & SCB_INTR_RX_NOT_EMPTY_Msk;

UartRxDat = Cy_SCB_UART_Get(UART_HW);

UartRxFlag = 1;

    }

}

void SysTickIsrHandler(void)

{

SysTickCnt ++;

}

int main(void)

{

uint16_t i = 0;

Cy_SysTick_Init(CY_SYSTICK_CLOCK_SOURCE_CLK_IMO,7999);

for (i = 0u; i < CY_SYS_SYST_NUM_OF_CALLBACKS; ++i)

    {

        if (Cy_SysTick_GetCallback(i) == NULL)

        {

            Cy_SysTick_SetCallback(i, SysTickIsrHandler);

break;

        }

    }

cy_en_scb_uart_status_t init_status;

/* Start UART operation. */

    init_status = Cy_SCB_UART_Init(UART_HW, &UART_config, &UART_context);

    if(init_status!=CY_SCB_UART_SUCCESS)

    {

    }

Cy_SCB_UART_Enable(UART_HW);

/* Transmit header to the terminal. */

    Cy_SCB_UART_PutString(UART_HW, "\r\n**********************************************************************************\r\n");

    Cy_SCB_UART_PutString(UART_HW, "This is UART example, which uses User ISR to demonstrate UART operation\r\n");

    Cy_SCB_UART_PutString(UART_HW, "If you are able to read this text the terminal connection is configured correctly.\r\n");

    Cy_SCB_UART_PutString(UART_HW, "Start transmitting the characters to see an echo in the terminal.\r\n");

    Cy_SCB_UART_PutString(UART_HW, "\r\n");

/* Unmasking only the RX fifo not empty interrupt bit */

    UART_HW->INTR_RX_MASK = SCB_INTR_RX_MASK_NOT_EMPTY_Msk;

/* Interrupt Settings for UART */   

    Cy_SysInt_Init(&UART_SCB_IRQ_cfg, ISR_UART);

/* Enable the interrupt */

    NVIC_EnableIRQ(UART_SCB_IRQ_cfg.intrSrc);

__enable_irq(); /* Enable global interrupts. */

    /* Place your initialization/startup code here (e.g. MyInst_Start()) */

    for(;;)

    {

        /* Place your application code here. */

if(UartRxFlag == 1)

{

UartRxFlag = 0;

Cy_SCB_UART_Put(UART_HW,UartRxDat);

}

if(SysTickCnt >= 500)

        {

SysTickCnt = 0;

Cy_GPIO_Inv(LED_Green_P1_1_PORT,LED_Green_P1_1_NUM);

        }

    }

}

0 Likes
1 Solution

Hello Lei,

Can you please try the latest beta release of creator from this thread: PSoC Creator 4.2 Beta 2 Announcement! ?

I had tested your projects in the later builds and they seem to work fine - both the projects.

So try and let us know if you still face the issue with the latest build.

Regards,

Meenakshi Sundaram R

View solution in original post

0 Likes
6 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Can you please post your complete project or a shortened version that shows the error so that we all can have a look at all of your settings. To do so, use

Creator->File->Create Workspace Bundle (minimal)

and attach the resulting file.

Bob

0 Likes

Hello Bob,

Thanks for your reply.

I have the complete projects and test result(screen shot picture) :

Tested on PSoC 6 BLE Pioneer Kit.

1.UART_ISR.cyprj.Archive_Works Well.zip   Demo project, Systick 1ms Interrupt, with 500MS LED blink. Uart RX with interrupt and send back. All function run on Cortex-M4.

  After reset/power on, type"hello world from PSoC6!"

   PSoC6EVB.cywrk.Archive_Works Well.JPG shows the test result.

2.UART_ISR.cyprj.Archive_Problem.zip Demo project. Systick on Cortex-M0+, Uart on Cortex-M4.

After reset/power on, type"hello world from PSoC6!"

   PSoC6EVB.cywrk.Archive_Problem.JPG shows the test result. Seems some Byte was lost / wrong Rx/Tx.

Please kindly let me know if need any further information.

Thanks.

Best regards,

Lei

0 Likes

Hello,

I tested your both code on CY8CKIT-062-BLE and worked perfectly fine except that I had to change pin configuration for UART as Tx=P9[1] and Rx=P9[0]. When pins were set as Tx=P5[1] and Rx=P5[0] only UART transmission was working and reception was not working, I verified pin P5[0] of my kit and found it working when configured as input so no problem with pin when configured as input but don't know why it isn't working as RX. I know this sounds foolish but you can configure pins as Tx=P9[1] and Rx=P9[0] and see the result. Also there is no such message "hello world from PSoC6 Demo Board!" in your both projects.

0 Likes

Hello,

Thanks for your reply.

The "hello world from PSoC6 Demo Board!" is what i typed in the terminal. So if the uart works well, the character will loop back my UART.

I using P5[0] and P5[1] because they are connected with the on board kitporg so I can use USB for UART debug.

But the P5[0] and P5[1] can be used as UART pins without Systick funciton on cortex-M0+. I don't know if this is dual-core issue or something.

I will try to modify UART to P9 and try again.

Thank you!

Best regards,

Lei

0 Likes

Hello Lei,

Can you please try the latest beta release of creator from this thread: PSoC Creator 4.2 Beta 2 Announcement! ?

I had tested your projects in the later builds and they seem to work fine - both the projects.

So try and let us know if you still face the issue with the latest build.

Regards,

Meenakshi Sundaram R

0 Likes

Hello Meenakshi,

This issue cannot be reproduced when using the latest PSoC Creator.

Thanks for your kindly help.

Best regards,

Lei

0 Likes