cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 6 MCU

MotooTanaka
Esteemed Contributor

Hi,

While I was trying to port my TinyBasic Sample of PSoC 4 (and 5LP) to PSoC 6

I encountered an interesting difficulty.

Tiny Basic for PSoC (CY8CKIT-044 / TSoC / CY8CKIT-059 / CY8CKIT-062-BLE)

I used CY8CKIT-062-BLE (without e-Ink display).

What I was trying was registering my isr to uart's external interrupt.

The schematic was

000-schematic.JPG

And in my tty initialization I wrote

=======================

void tty_init(void)

{

    Cy_SysInt_Init(&tty_rx_int_cfg, tty_rx_isr) ;

    NVIC_ClearPendingIRQ(tty_rx_int_cfg.intrSrc) ;

    NVIC_EnableIRQ((IRQn_Type)tty_rx_int_cfg.intrSrc) ;

    UART_Start() ;

}

=======================

Then I got an error

===========

prj.M0120:Build error: 'tty_rx_int_cfg' undeclared (first use in this function)

===========

So I tried to "Go to definition" of "tty_rx_int_cfg"

Then it was in cyfitter_sysint_cfg.h

===============

/* ARM CM4 */

#if (((__CORTEX_M == 4) && (CY_CORE_ID == 0)))

    #define tty_rx_int__INTC_ASSIGNED 1u

    extern const cy_stc_sysint_t tty_rx_int_cfg;

#endif /* ((__CORTEX_M == 4) && (CY_CORE_ID == 0)) */

===============

and in cyfitter_sysint_cfg.c

===============

#include "cyfitter_sysint.h"

#include "cyfitter_sysint_cfg.h"

/* ARM CM4 */

#if (((__CORTEX_M == 4) && (CY_CORE_ID == 0)))

    /* tty_rx_int */

    const cy_stc_sysint_t tty_rx_int_cfg = {

        .intrSrc = (IRQn_Type)tty_rx_int__INTC_NUMBER,

        .intrPriority = tty_rx_int__INTC_CORTEXM4_PRIORITY

    };

#endif /* ((__CORTEX_M == 4) && (CY_CORE_ID == 0)) */

===============

To test if this source is valid in my project,

I added

#define ISR_ASSIGNED 1

in the previous line of /* ARM CM4 */

and from the main.c ISR_ASSIGNED was 1.

So I assumed that cyfitter_sysint_cfg.c is linked.

Then I wonder why tty_rx_int_cfg came out to be undeclared?

Since I wanted to build this project anyway, I added same declaration inside my function,

==============

void tty_init(void)

{

#if 1

     /* tty_rx_int */

    const cy_stc_sysint_t tty_rx_int_cfg = {

        .intrSrc = (IRQn_Type)tty_rx_int__INTC_NUMBER,

        .intrPriority = tty_rx_int__INTC_CORTEXM4_PRIORITY

    };

#endif

    Cy_SysInt_Init(&tty_rx_int_cfg, tty_rx_isr) ;

    NVIC_ClearPendingIRQ(tty_rx_int_cfg.intrSrc) ;

    NVIC_EnableIRQ((IRQn_Type)tty_rx_int_cfg.intrSrc) ;

    UART_Start() ;

}

==============

Then the project could be compiled and the TinyBasic seems to be working OK.

But I still wonder why I needed to this.

Did I forget something to make the declaration in the "cyfitter_sysint_cfg.c" valid?

Or am I doing something (anything?) wrong with preparing a project for PSoC 6?

Any suggestion(s) and/or help(s) will  be greatly appreciated.

moto

0 Likes
1 Solution
RyanZhao
Moderator
Moderator

Tanaka-san,

Sorry sincerely for the late.

I added following extern const definition in tty_utils.c.

extern const cy_stc_sysint_t tty_rx_int_cfg;

The code can also work. I think the original code didn't identify the externl declaration in cyfitter_sysint_cfg.h...

Best Regards,

Ryan

View solution in original post

0 Likes
4 Replies
RyanZhao
Moderator
Moderator

Just guess some optimization configuration(s) is(are) different.. I will check the project.

Thanks,

Ryan

MotooTanaka
Esteemed Contributor

Dear Ryan-san,

Thank you for your response.

I tried with Optimization option of None, Normal, and Exhaustive.

But all failed with the same error...

Interesting enough, the IDE is noticing the definition,

I wonder how the compiler could get rid of the variable...

Since it's April Fool, the compiler may work tomorrow though.

Best Regards,

1-Apr-2020

Motoo Tanaka

0 Likes
RyanZhao
Moderator
Moderator

Tanaka-san,

Sorry sincerely for the late.

I added following extern const definition in tty_utils.c.

extern const cy_stc_sysint_t tty_rx_int_cfg;

The code can also work. I think the original code didn't identify the externl declaration in cyfitter_sysint_cfg.h...

Best Regards,

Ryan

View solution in original post

0 Likes
MotooTanaka
Esteemed Contributor

Dear Ryan-san,

Thank you very much for your answer.

I aslo tried adding

     extern const cy_stc_sysint_t tty_rx_int_cfg;

in tty_utils.h and it also workd.

> I think the original code didn't identify the externl declaration in cyfitter_sysint_cfg.h...

I wonder if this is something we all should know?

Best Regards,

23-Apr-2020

Motoo Tanaka

0 Likes
Top labels