- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to create alternating pulses on two pins of a CY8C29466 and display a count of the pulses on an LCD character display. The attached code works to some extent, but basically the pulses stop alternating between the two pins after 10 cycles. I am using a counter to generate an interrupt and throw a flag that I am checking for in the main loop. Once the interrupt flag is detected, a second flag is toggled that should alternate what pin the pulse appears on. Relevant code:
if (countFlag == TRUE)
{
Pin_C_Data_ADDR ^= Pin_C_MASK;
if (turnA == 0x0)
{
Pin_A_Data_ADDR |= Pin_A_MASK;
for (i = 0; i < 5000; i++);
Pin_A_Data_ADDR &= ~Pin_A_MASK;
turnA = 0x1;
}
else if (turnA == 0x1)
{
Pin_B_Data_ADDR |= Pin_B_MASK;
for (j = 0; j < 5000; j++);
Pin_B_Data_ADDR &= ~Pin_B_MASK;
turnA = 0x0;
count++;
LCDUpdate = TRUE;
}
countFlag = FALSE;
}
I do not understand why this isn't working after 10 cycles. Any ideas?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The line
itoa(&countA, count, 10);
destroys your data. countA is not defined as a character array as it should be. So all data will be overwritten with the resulting string of the conversion.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The line
itoa(&countA, count, 10);
destroys your data. countA is not defined as a character array as it should be. So all data will be overwritten with the resulting string of the conversion.
Bob