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

PSoC™ 5, 3 & 1 Forum Discussions

Naz99
Level 3
Level 3
10 likes given 25 sign-ins 5 questions asked

hello, I am using psoc 5lp cy8ckit-059 prototyping kit. I am planning to create a project that can switch to 3 different circuit designs/ modes which I have designed in separate projects as in attachment. Is there any methods to do this or should I just need to only use one project that combine the circuit to do this?

0 Likes
1 Solution
Len_CONSULTRON
Level 9
Level 9
500 solutions authored 1000 replies posted 750 replies posted

Naz99,

I believe the attached project is what you are looking for.

I combined ALL three modes into one project.  All but one of the modes is enabled by disabling the schematic pages in TopDesign for the other modes.

To change modes:  FIRST disable the schematic page of the currently active mode.   Then enable the desired mode.   It may or may not warn that signal names need to be assigned,  This is not an issue.

If you don't FIRST disable the previous mode page before enabling the next mode page, Creator will complain that the newly enabled page has components with name collisions.  It will ask if you want to rename the components on the newly enabled page.  This is not what you want.

I use this technique of multiple schematic pages all the time.

Here's an additional feature when using this method:

When you "Application Build" your project, you will find a file "Generated_Source/cydisabledsheets.h".

Inside the file you'll find something like this:

 

#ifndef INCLUDED_CYDISABLEDSHEETS_H
#define INCLUDED_CYDISABLEDSHEETS_H

#define Mode_1__DISABLED 1u /* Mode_1 */
#define Mode_3__DISABLED 1u /* Mode_3 */

#endif /* INCLUDED_CYDISABLEDSHEETS_H */

 

 It will have a #define of the disabled sheets.

This allows you to create conditional compile instructions.   This would allow you to determine which line(s) of code to use for the compile/link phase.  For example:

 

#if (Mode_1__DISABLED) && (Mode_3__DISABLED)
// These lines here will be valid if both Mode_1__DISABLED and Mode_3__DISABLED sheets are disabled.
#endif

#if !(Mode_2__DISABLED)
// These lines here will be valid if Mode_2__DISABLED is not found.
#endif

#if !defined(Mode_2__DISABLED)
// These lines here will be valid if Mode_2__DISABLED is not found.
#endif

 

 

Len
"Engineering is an Art. The Art of Compromise."

View solution in original post

17 Replies
pacr_284376
Level 5
Level 5
50 sign-ins 10 likes received 5 likes given

 

It depends... Who can switch between mode 0/1/2 ?

Try putting it in 1 project as much as possible, it makes changing code and testing much easier

If multiple projects needed, try working with libraries as much as possible. If you change e.g. the UART routines I guess you dont want to change it in all different projects.

0 Likes
Len_CONSULTRON
Level 9
Level 9
500 solutions authored 1000 replies posted 750 replies posted

Naz99,

I believe the attached project is what you are looking for.

I combined ALL three modes into one project.  All but one of the modes is enabled by disabling the schematic pages in TopDesign for the other modes.

To change modes:  FIRST disable the schematic page of the currently active mode.   Then enable the desired mode.   It may or may not warn that signal names need to be assigned,  This is not an issue.

If you don't FIRST disable the previous mode page before enabling the next mode page, Creator will complain that the newly enabled page has components with name collisions.  It will ask if you want to rename the components on the newly enabled page.  This is not what you want.

I use this technique of multiple schematic pages all the time.

Here's an additional feature when using this method:

When you "Application Build" your project, you will find a file "Generated_Source/cydisabledsheets.h".

Inside the file you'll find something like this:

 

#ifndef INCLUDED_CYDISABLEDSHEETS_H
#define INCLUDED_CYDISABLEDSHEETS_H

#define Mode_1__DISABLED 1u /* Mode_1 */
#define Mode_3__DISABLED 1u /* Mode_3 */

#endif /* INCLUDED_CYDISABLEDSHEETS_H */

 

 It will have a #define of the disabled sheets.

This allows you to create conditional compile instructions.   This would allow you to determine which line(s) of code to use for the compile/link phase.  For example:

 

#if (Mode_1__DISABLED) && (Mode_3__DISABLED)
// These lines here will be valid if both Mode_1__DISABLED and Mode_3__DISABLED sheets are disabled.
#endif

#if !(Mode_2__DISABLED)
// These lines here will be valid if Mode_2__DISABLED is not found.
#endif

#if !defined(Mode_2__DISABLED)
// These lines here will be valid if Mode_2__DISABLED is not found.
#endif

 

 

Len
"Engineering is an Art. The Art of Compromise."

thank you for the answer. I manage to switch to other mode after following your guide. Also, can I switch the modes using a button to make it easier to switch?

0 Likes

Naz99,

... can I switch the modes using a button to make it easier to switch?

On the PSoC5 you have 4 VDACs available and 4 SC blocks (for the PGAs).

To incorporate ALL your 3 modes into one active schematic you will need:

  • 8 VDACs
  • 6 PGAs.

You will be 4 VDACs and 2 PGAs short.

Len
"Engineering is an Art. The Art of Compromise."
0 Likes

Naz99,

Here's a modified project with a combined modes 1, 2 and 3.

It's not optimal for many reasons but can generally work if you set the correct settings.

 

Len
"Engineering is an Art. The Art of Compromise."

thanks for the help. I am currently working with the code. will do my best on this project

 

0 Likes

I have done the coding but it seems like my coding is wrong because there is no value appear in serial display. would you mind checking it? I am sorry I am not good at coding psoc

0 Likes

Naz99,

Something was screwed up about your .cydwr file.   When I went to select the "DWR/Pins" to look at the setting of your URT pins, it would come up.

The project however built without complaint.   I also received no UART output when I should have.

To fix the issue I renamed the project.   Doing so yielded an error.  However I was now able to select "DWR/Pins".   The pin assignment for the UART was correct.

A new build and program now yielded UART terminal output.  (Yeah!!!) even though the data was wrong.

Len
"Engineering is an Art. The Art of Compromise."
0 Likes

Naz99,

I've modified your project and can now switch modes on-the-fly by typing:

- '1' for mode 1

- '2' for mode 2

- '3' for mode 3

This might not be exactly what you're expecting but you can use it as a guide for further development.

Note:  I got rid of the two other Debouncer components.   I use the same one Debouncer using P2.2 on the CY8CKIT-059.

Once you're in a new mode, pressing and releasing SW1 (P2.2) will change the InputMux channel setting the input for ADC conversion.

Len
"Engineering is an Art. The Art of Compromise."

thank you so much for modifying my coding. However, when the program is running, the serial terminal display random characters after working well for a second as in image below. any idea how to fix this problem?

mode combine UART.png

 

0 Likes

Naz99,

I suspect when you push SW1 you are jostling the USB connection to the UART.  

I have my Cy8CKIT-059 in a small vise to eliminate this issue.

Len
"Engineering is an Art. The Art of Compromise."

thanks for the advice. I solved the problem after configuring the UART setting bps from 115200 to 9600.  everything works well. thanks again for helping me 🙂

0 Likes

Naz99,

Sorry.  I routinely use 115.2K for my UART comm.  That way since most of my UART comm is blocking, it doesn't take as long to send (or receive).

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
pacr_284376
Level 5
Level 5
50 sign-ins 10 likes received 5 likes given

"It depends... Who can switch between mode 0/1/2 ?" 

"Also, can I switch the modes using a button to make it easier to switch?"

So the modes need to be switched during runtime. Do you have the possibility to combine it in one diagram ? 

 

0 Likes

I think it is not possible to put all of them in one schematic since it uses same components

0 Likes
pacr_284376
Level 5
Level 5
50 sign-ins 10 likes received 5 likes given

Keep on trying to make it fit. Otherwise, you could maybe provide the processor with multiple applications - see AN73854 "Introduction to Bootloaders"... I'm not sure how many applications you could use, might be only 2

thank you for your help. I will try my best on this project.

0 Likes