- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm using a PSOC 5LP.
This code works..
for(;;)
{
if (LightItUp_Read() != lightState)
{
lightState = LightItUp_Read();
if (lightState)
DebugPort_PutString("Light On\r\n");
else
DebugPort_PutString("Light Off\r\n");
}
}
But this doesn't..
for(;;)
{
lightState = LightItUp_Read();
if (lightState)
DebugPort_PutString("Light On\r\n");
else
DebugPort_PutString("Light Off\r\n");
CyDelay(1000);
}
Can someone please explain ?
Message was edited by: Ajinkya Bansod Added new project
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you want to use the USBUART as a logging, it is better to implement a FIFO.
Please let me introduce my repository on github. In the project example FIFOs are implemented to the TX and RX of USBUART.
Regards,
Noriaki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Would you explain what you mean by "works" and "doesn't"?
(1) It does not even compile?
(2) Does it stall or crash the program at some point?
(3) Does it run but no output displayed?
(4) Does it run but only one type of output displayed?
It would be nice if you can attach an archive of the project or sample project
which we can reproduce the problem.
Please refer to the following discussion about about how to attache a project.
How to attach a project archive file to a question?
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Having written my previous response,
I would try to check following things.
Are they different projects or just changing source in the same project?
(1) If they are different projects.
I would copy the working project to another name and copy only the different part of the "not working" source and try it.
(2) If they are the same project. (Only the source is modified) the only difference I could notice was
the number of LightItUp_Read() calls.
When it is working the function is called twice.
When it does not it is being called only once.
I wonder if you try
=================
for(;;)
{
lightState = LightItUp_Read(); /* to avoid this line to be optimized, please add volatile to the difinition of lightState */
lightState = LightItUp_Read();
if (lightState)
DebugPort_PutString("Light On\r\n");
else
DebugPort_PutString("Light Off\r\n");
CyDelay(1000);
}
=================
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
By "doesn't work" I mean no data is displayed on serial terminal of computer.
I can't find anything to upload rar here. This is my whole code.
#include "project.h"
int main(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
uint8 lightState = 0;
/* Place your initialization/startup code here (e.g. MyInst_Start()) */
DebugPort_Start(0, DebugPort_5V_OPERATION);
for(;;)
{
/* Place your application code here. */
//if (LightItUp_Read() != lightState)
{
lightState = LightItUp_Read();
if (lightState)
DebugPort_PutString("Light On\r\n");
else
DebugPort_PutString("Light Off\r\n");
}
CyDelay(1000);
}
}
Thanks for giving your precious time to help the community.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
> By "doesn't work" I mean no data is displayed on serial terminal of computer.
OK, thank you for the answer.
I have a couple of questions.
(1) What is your development environment? (PSoC Creator, MDK Keil, IAR EWARM or something else?)
(2) What component is "LightItUp"? GPIO input, or something else?
> I can't find anything to upload rar here. This is my whole code.
Have you checked the link?
How to attach a project archive file to a question?
If you are using a PSoC Creator there should be many more files to be archived to reproduce "your project"
Meantime, have you had chance to download and test NoriakiT_91-san's sample(s)?
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok.. Thanks for the info.
I've attached project.
What I need is a basic USBUART to output debug info via USB to computer. But when I try to periodically send data, I don't get data on terminal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi!
I'm using PSOC creator. Lightitup is my LED status.
I just tested Noriaki's sample. It works fine. My mistake was I wasn't waiting for USB to complete initialization as done by Mr Noriaki. I added that part to my code and it works fine.Thanks NoriakiT_91 and MoTa_728816 !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you want to use the USBUART as a logging, it is better to implement a FIFO.
Please let me introduce my repository on github. In the project example FIFOs are implemented to the TX and RX of USBUART.
Regards,
Noriaki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey Noriaki!
I used the FIFO USBUART code with my I2C code and it worked fantastically.
Now I'm trying to use Systicktimer with it and it is causing issues.
Does USB timer and Systicktimer clash?
I tried to debug but the code gets stopped at
// Wait for initialization completed
while (USBUART_GetConfiguration() == 0);
The initialization never completes and code gets stuck at this while loop.
I have attached the project to question.
Please guide.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you have any trouble to USB when the systick timer is used, it is supposed that the Interrupt Service Routine (ISR) for the SysTick timer consumes CPU for long time.
Because the SysTick timer's priority is very high, please reduce the required time in that ISR.
Please check if there is a loop in the ISR waiting fro external events.
Regards,
Noriaki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey Motoo!
I used the FIFO USBUART code with my I2C code and it worked fantastically.
Now I'm trying to use Systicktimer with it and it is causing issues.
I have attached the project to question.
Does USB timer and Systicktimer clash?
I tried to debug but the code gets stopped at
// Wait for initialization completed
while (USBUART_GetConfiguration() == 0);
The initialization never completes and code gets stuck at this while loop.
Please guide.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Noriaki!
I will test it and let you know.