- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
First, I just found out what ISR means. I did not create this program, and have little practical experience with interrupts.
I just took out the UART (datasheet), and in its place put the SCB (datasheet).
Now the main.c file has errors (and warnings) in this function:
CY_ISR(InterruptHandlerDMXIn)
{
// Read status, and clear interrupt
int status = UART_DMX_ReadRxStatus();
// Get location of pointer
ptrdiff_t ptrIndex = dmxReadPtr - DMXReadBuffer;
// Check for break
if(status & UART_DMX_RX_STS_BREAK)
{
// Reset pointer
dmxReadPtr = DMXReadBuffer;
// Update TX data
writeFlag = TRUE;
// Clear buffer
UART_DMX_ClearRxBuffer();
}
// If data ready, read data and write to next device with address skip
if(status & UART_DMX_RX_STS_FIFO_NOTEMPTY)
{
// if the pointer is smaller than the size of the DMX packet, process
if(ptrIndex < DMX_SIZE)
{
// Read data
*dmxReadPtr = UART_DMX_ReadRxData();
// Send the data to the next light when the pointer exceeds the address (first four bytes)
if(ptrIndex > 4)
{
UART_DMX_PutChar(*dmxReadPtr);
}
// Increment pointer
dmxReadPtr++;
}
else
{
// Clear buffer
UART_DMX_ClearRxBuffer();
}
}
}
- UART..ReadRxStatus();
- UART..RX_STS_Break
- UART..ClearRxBuffer();
- UART..RX_STS_FIFO_NOTEMPTY
- UART..ReadRxData();
- etc.
There are so many subfolders, I do not know how to go about changing the old program to accommodate the changed schematic blocks. Any pointers, and just general tutorials on how to understand what is going on in the main.c file?
(I can foresee me changing this whole program for a more recent IC.)
Solved! Go to Solution.
- Labels:
-
PSoC 4 MCU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Yes, I wish the maker had provided "compatibility" between these components.
Anyway, if I were you would try to create a header to bridge between those.
Something like
uart_utils.h
#ifndef _UART_UTILS_H_
#define _UART_UTILS_H_
#include "project.h"
#define UART_DMX_ReadRxStatus() UART_DMX_GetInterruptCause()
#define UART_DMX_RX_STS_BREAK UART_DMX_INTR_RX_NOT_EMPTY
...
#endif /* _UART_UTILS_H_ */
and include this header in the source files which uses UART.
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I tried to create a blank project with SCB UART (UART_DMX) and tried search and fit APIs/Definitions using CY8CKIT-044.
CY_ISR(InterruptHandlerDMXIn)
{
// Read status, and clear interrupt
int status = UART_DMX_GetInterruptCause() ;
UART_DMX_rx_ClearInterrupt() ;
// Get location of pointer
ptrdiff_t ptrIndex = dmxReadPtr - DMXReadBuffer;
// Check for break
if(status & UART_DMX_INTR_RX_NOT_EMPTY)
{
// Reset pointer
dmxReadPtr = DMXReadBuffer;
// Update TX data
writeFlag = TRUE;
// Clear buffer
UART_DMX_CLEAR_RX_FIFO ;
}
// If data ready, read data and write to next device with address skip
if(status & UART_DMX_INTR_RX_NOT_EMPTY)
{
// if the pointer is smaller than the size of the DMX packet, process
if(ptrIndex < DMX_SIZE)
{
// Read data
*dmxReadPtr = UART_DMX_UartGetByte(); //
// Send the data to the next light when the pointer exceeds the address (first four bytes)
if(ptrIndex > 4)
{
UART_DMX_UartPutChar(*dmxReadPtr);
}
// Increment pointer
dmxReadPtr++;
}
else
{
// Clear buffer
UART_DMX_CLEAR_RX_FIFO ;
}
}
}
Now the good news is that the project can be compiled,
but the bad news is that I can't check if this works within your context.
I hope that at least this can be some starting point for you.
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- UART..ReadRxStatus()
- UART..GetInterruptCause()
- UART..RX_STS_Break
- UART..INTR_RX_NOT_EMPTY
- UART..ClearRxBuffer()
- UART..CLEAR_RX_FIFO
- UART..RX_STS_FIFO_NOTEMPTY
- UART..INTR_RX_NOT_EMPTY
- UART..ReadRxData()
- UART..UartGetByte
- UART..PutChar
- UART..UartPutChar
- TX_Write
- UART_DMX_tx_Write
I will likely have to change the whole program again for a newer IC. I did not create the main.c program, and do not really understand large parts of it. Is the quick and dirty way of changing the API calls and variables to just look in related word .h files?
Some of the variables deeper into the program broke, and that is where I guessed seemingly equivalent names. Although, I doubt I would have guessed something like `ReadRxStatus` would be `GetInterruptCause`.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Yes, I wish the maker had provided "compatibility" between these components.
Anyway, if I were you would try to create a header to bridge between those.
Something like
uart_utils.h
#ifndef _UART_UTILS_H_
#define _UART_UTILS_H_
#include "project.h"
#define UART_DMX_ReadRxStatus() UART_DMX_GetInterruptCause()
#define UART_DMX_RX_STS_BREAK UART_DMX_INTR_RX_NOT_EMPTY
...
#endif /* _UART_UTILS_H_ */
and include this header in the source files which uses UART.
moto