- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Every one
Thank you for the possibility to ask questions here.
This may be a silly question.
Assume that you are verified that all project's components are correctly started and the variables that should be initialized are OK.
What can be the reason that certain code just run ok one time after the end of chip's program from PSoC Creator or after Power on Reset ?
Thank you very much foe any help.
Regards
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Stack corruption is the most probable reason for that. Post your project and we check it.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob
Thank you.
I will do some cosmetic to the code because comments are a mix between English/Spanish and I will post it.
thank you again
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob
Please see attached bundle.
The project is about a star network through Infrared link with a kind of RC5 encoding scheme.
The attached project has an IrGateway Project which send messages to the different sensors in loop fashion , with a time gap between messages.
That message is to address a different sensor through the sensor number and sensor type.
The sensor 'answer sending data trough a payload is not yet implemented.
I'm stuck at this point: Sending the request - the sensor board capability to recognize that the message is for it.
How the project is implemented:
For the IrGateway project I am using a CY8CIKit-050.
Currently I have implemented only two sensors with CY8CKIT-059 each one.
Actually there is not sensor at all at this point.
I 'm only sending a constant value as request for each sensor.
That constant value include Sensor number and sensor type plus Header/ Preamble and CRC.
Facts:
1-Trough Debugging I verified that each sensor receive its payload correctly .
1-Trough the scope I verified that the pulse train send to each sensor is OK.
2-Each sensor board has an additional led which show me with short blink that the message was not addressed to it and with long Blink when the message was addressed to it.
3-At IrGateway Project the main loop is just set sensor number in a SN variable and call a function which does the request first for sensor #0 wait 2 seconds and it does a same with sensor #1.
Issue #1: each sensor board recognize that a payload was received but issue a short blink showing me that the message was not addressed to it, which is not true (point 1).
Issue #2: While the IrGateway board is sending messages , if I do a power cycle the code run correctly just once afterward.
Issue #3: The same as issue #2 happens once I finish to flash the code.
Note: I am not professional programmer neither Psoc 5 expert.
I hope it is clear enough so you can help me with that.
Thank you so much.
Best regards,
Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob again !
I forgot to tell you that each couple IrGateway - Sensor# is working OK separately beside that it is necessary to do a power cycle or flash the code so that it start running.
I only get the code running with the following to conditions:
Condition #1
Gateway - Sensor #0 is working Ok - Sensor 1 just recognize a wrong request.(Payload)
int main()
SN=0;
RqtsAnswer( SN );
CyDelay(2000);
// SN=1;
// RqtsAnswer( SN );
// CyDelay(2000);
Condition #2
Gateway - Sensor #1 is Ok - Sensor 0 just recognize a wrong request ( Payload)
int main()
SN=0;
RqtsAnswer( SN );
CyDelay(2000);
SN=1;
RqtsAnswer( SN );
CyDelay(2000);
The worse issue is as I mentioned in the last post.:
int main()
SN=0;
RqtsAnswer( SN );
CyDelay(2000);
SN=1;
RqtsAnswer( SN );
CyDelay(2000);
Additional info
The receiver is a TSOP 36436 hooked up to Demod_input on each receiver,
Thank you very much
Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Alex, it is too difficult to follow with just some code snippets.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob
How should I send you the 344 MB bundle ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Delete the generated files and clean the project before building the bundle.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob
Ok
Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob
I did like you told me, but in spite to deleted all generated source and clean all project, the zip is very heavy, around 340 MB.
Please see the attached one which has the Standard Cypress Libraries deleted.
Let me know if it does work, if doesn't I can send PDF for each file
Thank you very much.
Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please debug your project and check whether it is going to an infinite loop-
CY_ISR(IntDefaultHandler)
{
while(1)
{
/***********************************************************************
* We must not get here. If we do, a serious problem occurs, so go
* into an infinite loop.
***********************************************************************/
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Anks
Thank you very much for your help.
Could you please be a little be more specific about what I should do?
There are one Emitter and two receivers.
On pervious post I've mentioned that the each Emitter-Receiver work OK but in this case 80% the time the code start running only if I do a power-cycle or I flash the code into the Psoc5 device.
So in what situation I need to insert this snippet?
CY_ISR(IntDefaultHandler)
{
while(1)
{
/***********************************************************************
* We must not get here. If we do, a serious problem occurs, so go
* into an infinite loop.
***********************************************************************/
}
}
On the Emitter, on the receiver or over the three boards.
Sorry if I do not understand your valuable help.
Thank you
Alex.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Anks
Thank you for your help.
Can you be more specific about where I need to insert that loop please?
I mean, on the Emitter end or Receivers end. - There are to receiver end by now.
Thank you for your valuable help
Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This loop already exists in cyboot.c. When your project gets stuck when debugging, halt it and see where you are. The call stack will be of much help. That above loop is called in case of dramatic errors as addressing non-existing memory, invalid instruction and similar catastrophes.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob and Anks
Thank you very much both of you.
I will try that.
Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob and Anks
I've done most of the possible tests with debugger but in no case the code is inside the loop you mentioned.
Call Stack always indicates the correct sequence should follow the debugger
Another strange aspect is that with the CY8CKIT-059 is not possible to use the option debug without programming, because PSoC Creator throw an error, Please see attached PDF.
Perhaps this is related to the fact that IrSensor project starts running only after being downloaded to Flash or made power cycle.
By the way do you know when the component Timer V 1.50 will be released?
I saw preliminary data sheet.
I am stuck with this project.
Do you have some other suggestion?
Thank you very much
Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob And Anks
When I was starting this project I got stuck trying to receive the payload signal with the IrGateaway receiver or IrSensor receiver. Just after reset the board or after flashing the code I was able to get using the debugger a correct payload. So that I decided to file a support case.
I sent the project and I have received this answer
Support case commentary:
"We have verified your design. With a test value at the received data word ,it seems to be working fine. So the delay is when the receiver is waiting for the data. When the timer is setting the period value according to the received bit at the IR receiver, that delay is occurring. Instead of 889us, you are receiving 980us right?.We have faced this kind of delay problem in one our earlier project due to the set_divider API in the clock. Once the time period is changing, the clock signal has to be modified accordingly. Here also, with the received bit, you need to change the time period. This set divider API in clock actually modifies the clock value for the timer by division. But this API have a defect which causes some delay in the output."
Thanks,
Athira
I did not understood what Athira wanted to tell me. I asked him or her for some explanation but never was clear enough at least for me .
After those answer I continued verifying my code and I found that the reason I did not receive the correct payload was because the timer at the receiver was setting the 1/4 of bit time just once, at the start of the code, and after that always the Timer's period was 1.778 ms. That was prevent the to code synchronize the incoming bits.
Just it was a matter to introduce the correct instruction in the correct place and the code started to run with some issues.
Inspired for the Athiras's word I introduced some delay in the order of us before the Domod_pin.
was read (look at IRSensor or IrGateway ).
OK, that was the magic solution. From there the code started to run smoothly.
You can look at that in the Receive_Word() function.
But this only have worked whit CY8CKIT050.
I add a delay to the code that IrSensor code that run on CY8CKIT-059 and it doesn't operate at all.
OK this just a commentary for help ypu to help me.
Thank you very much for your valuable time.
Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob and Anks
After much analysis and test the code I found the solution.
The problem was generated by improper initialization of an array.
Please see attached function code.
I cannot explain why but the code is working.
However there remain the problems with starting the code.
Moreover I continue to add some delay before reading the pin receiving infrared pulse train.
You can see that at function "Received_Word" which is called by "GatewayIrRx".
That delay is related to the last post I sent you .
If you have some suggestion for the issue with starting the code will be very appreciated.
I hope that the new Timer 1.50 version will overcome this issue.
I am working on the answer of each sensor which send the reading value.
Thank you very much.
Bets regards,
Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob
I would need your always valuable help.
Regarding the above posted project, I mean the infrared link, I am facing an issue related to an empty While loop. It is waiting for the ISR set a flag when an edge from the infrared payload are being received.
You can take a look at that in the "Received_Word()Function" which include " while (Pin_Flag!=1) {;}.
The point is the this:
I am intending to do a polling for read data from the set of sensors.
In the case one sensor doesn't work I should repeat the request x times.
Here is the issue: if the sensor doesn't work there is no payload, there is no edge detection on the GatewayIrRx project (please refer to the bundle I sent you), as consequence the above mentioned loop
" while (Pin_Flag!=1) {;} " never end and the code get stuck at this point.
I have tried some sort of timeout so that after some time if there is no edge detected the code can exit from that loop. I was thinking about to use a RTC component with the 1PPS feature but It seems to me that it would be the same, I mean I'll need to detect other flag, the one from the RTC.
I know that it is not an PSoC5LP issue, it's just some help I am asking you.
Do you have some suggestion about that?
Thank you in advance.
Best regards,
Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To talk in pseudo-code you need
TimeoutStart
while ((not timeout) and (Pin_Flag not equal to 1) Wait
If (timeout) Set Sensor error
You see you will need a timer component or you use a counter to limit the while-loop duration.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob
Thank you for that suggestion I'll give a try.
Regards,
Alex