Re: UART Communication block

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

cross mob
lock attach
Attachments are accessible only for community members.
misa_4395186
Level 2
Level 2
First like given

what I am trying to do is pass different period values (2 bytes) to counter 1, 2, and 3 through the hyper terminal (have them saved in a memory or buffer) then after I do a an external reset my outputs from the TCPWM will all start at the same time (by the aid of the one shot counter 4) and they will use the period values I input through the terminal. What I am currently stuck at is how do I change the fixed period values every time I do an external reset (is there a way to pass new period values for the TCPWM and have them sit in a buffer or internal memory until I change them again). And how to I combine two bytes from the hyper terminal and use this value to pass unto the period register, any help or direction is greatly appreciated

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

Thanks for this three days weekend in Japan, I had some time to play with my PSoC board.

I tried with CY8CKIT-044, so pin and other config may different with yours.

And this is a quick prototype so (as usual) may not work correctly.

Having written that, as you were writing that you want to run the board with given setting after reset,

I assumed that you need some non volatile memory to store the configuration.

So I used Em_EEPROM.

000-schematic.JPG

Note: The fourth PWM is used to generate 25kHz external clock, so if you have an external 25kHz clock

this PWM is not required. (I jumpered Clock_Out_25KHz with Clock_In_25KHz outside the board).

As you were using most of ISRs only to flip the signal, instead I used TCPWM with period and compare.

And I cheated terminal I/O using my tty utility sample.

When my program is down loaded to the board and get reset, its Em_EEPROM has no content

so the program uses the default value and start running after setting the default values.

000-teraterm.JPG

001-oscillo.JPG

All three signals are running with period = 100 and compare = 50.

(Actually in the TCPWM 99 and 49)

Then I stopped the PWM by typing "stop".

I could type "stop 1" to stop counter1, "stop 2" for Counter 2, "stop 4" for Counter3.

So typing stop is equal to typing "stop 7"

Then I set period of Counter2 to 200 by typing "period 2 200"

period of Coutner3 to 300 by typing "period 4 300" (Note period 3 300 will set Counter1 and Counter2 to 300)

Then again started all by typing "start"

002-teraterm.JPG

003-oscillo.JPG

Then to test "save" function, I typed "save" which will save current settings to Em_EEPROM.

Then I hit "reset" button of the board.

So the greeting message was displayed but this time each pwm has different values,

which was read from Em_EEPROM.

003-teraterm.JPG

The waves on my Oscilloscope.

004-oscillo.JPG

At first I was trying to make the project simple, but I'm afraid that I failed to accomplish orz.

Anyway, yet another sample for you 😉

moto

View solution in original post

0 Likes
8 Replies
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

misa,

You can use this demo project as an example.

Re: How to use 4 Uart in Psoc 4

It uses UART to receive commands from terminal and updates PWM duty cycle on  RGB LEDs.

New value written to the Counter will take effect  after reset.

About reset: is this external PSoC system reset or standard Counter reset through "res" terminal?

/odissey1

UART_SCB_Rx_01.png

0 Likes
lock attach
Attachments are accessible only for community members.

Thank you odissey1!! your example project was very helpful, I implemented it to my 3 counters instead of your 3 PWM and changed "PWM_WriteCompare" api to "Counter_WritePeriod" and kept all of your code structure the same. I was happy to see it build and program into my Cy8CKIT-043 without any issues. Before I further modify the code for my application I am running into some problems: First, I can read what the program sends to the hyper terminal (i.e. PWM + UART example type a command...) but I do not see any echo (when I try to type anything on the keyboard nothing shows up on my terminal). Second, my TCPWM counter output frequencies are changing and not fixed to a certain frequency when I send an external clock (using a function generator), I am not sure what could be causing this as I don't have good understanding of the code. I have attached the project file, I I hope it is something just minor that I have wrong! Thank you for your help!!

0 Likes

Regarding the reset, it is the external reset signal (n-rst)

0 Likes

misa,

I am traveling this week and won't be able to check your project, hopefully someone else can.

In my demo, PWMs were using fixed function SCB, which only works with internal clocks, no external signal generator will do. Do you use external generator for reset?

This KBA might be helpful:

Best Practices to Reload the Compare and Period Values of Timer/PWM/TCPWM/Counter Component - KBA905...

I believe that in the demo, echo was enabled for errors only, but I might be wrong - too much time passed. Also some Terminal emulators do echo message themselves. Check that baud rate is the same on both ends.

/odissey1

0 Likes

Safe travels! I only use external generator to generate the input signal for my counters that will be divided down (based on the divisor number I input in the hyper terminal, through the Counter_WritePeriod API) . But I need an nRST signal that will sync all my output signals at To (time zero) right after I release my reset button, this is the only way I found to sync all my counter outputs frequencies at time zero

0 Likes

The PWM has the choice to enable a start and a stop input. You can controll al PWMs using a control register output and start all components at the very same time.

>Bob

0 Likes
lock attach
Attachments are accessible only for community members.

Thank you Bob for your feedback, ok I will stop the counter then write period and then then enable the counter. I have attached my block diagram to show what I am trying to do. I am not a coder and I am really stuck getting the UART communication firmware between the terminal and my counter APIs. I am also interested to sync all my output signals from my counters at Time zero and not necessary when my counter starts but making sure all my outputs from my counter toggle high when I let go of nRST, I drew it in the block diagram as well. I hope I made clear what I am trying to do thank you for your help!

0 Likes
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

Thanks for this three days weekend in Japan, I had some time to play with my PSoC board.

I tried with CY8CKIT-044, so pin and other config may different with yours.

And this is a quick prototype so (as usual) may not work correctly.

Having written that, as you were writing that you want to run the board with given setting after reset,

I assumed that you need some non volatile memory to store the configuration.

So I used Em_EEPROM.

000-schematic.JPG

Note: The fourth PWM is used to generate 25kHz external clock, so if you have an external 25kHz clock

this PWM is not required. (I jumpered Clock_Out_25KHz with Clock_In_25KHz outside the board).

As you were using most of ISRs only to flip the signal, instead I used TCPWM with period and compare.

And I cheated terminal I/O using my tty utility sample.

When my program is down loaded to the board and get reset, its Em_EEPROM has no content

so the program uses the default value and start running after setting the default values.

000-teraterm.JPG

001-oscillo.JPG

All three signals are running with period = 100 and compare = 50.

(Actually in the TCPWM 99 and 49)

Then I stopped the PWM by typing "stop".

I could type "stop 1" to stop counter1, "stop 2" for Counter 2, "stop 4" for Counter3.

So typing stop is equal to typing "stop 7"

Then I set period of Counter2 to 200 by typing "period 2 200"

period of Coutner3 to 300 by typing "period 4 300" (Note period 3 300 will set Counter1 and Counter2 to 300)

Then again started all by typing "start"

002-teraterm.JPG

003-oscillo.JPG

Then to test "save" function, I typed "save" which will save current settings to Em_EEPROM.

Then I hit "reset" button of the board.

So the greeting message was displayed but this time each pwm has different values,

which was read from Em_EEPROM.

003-teraterm.JPG

The waves on my Oscilloscope.

004-oscillo.JPG

At first I was trying to make the project simple, but I'm afraid that I failed to accomplish orz.

Anyway, yet another sample for you 😉

moto

0 Likes