- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am working on the challenge in the PSoC 101 tutorial video I2CReceive for the PSoC 4 pioneer kit.
I am attempting to write a byte value to two different PWMs at different memory addresses to control the brightness of the on-board LED.
However, I am only able to get a single PWM to work with the EZI2C receive module.
This is my code with comments to explain what I did in attempt to control two PWMs:
int main(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
uint8 compare1 = 0;
uint8 compare2 = 0;
/*increased i2cbuf size to 2 to accept two bytes*/
uint8 i2cbuf[2];
i2cbuf[0] = 0;
i2cbuf[1] = 0;
PWM_Start();
/*started second PWM module*/
PWM_1_Start();
I2C_Start();
/*increased size of i2c buffer to 2*/
I2C_EzI2CSetBuffer1( 2, 2, i2cbuf );
for(;;)
{
if (compare1 != i2cbuf[0])
{
compare1 = i2cbuf[0];
PWM_WriteCompare( compare1 );
}
/*added second compare statment to check if new data has been received*/
if (compare2 != i2cbuf[1])
{
compare2 = i2cbuf[1];
PWM_1_WriteCompare( compare2 );
}
}
}
In the bridge control panel, I send w 08 00 FF p and it works but when I send w 08 10 FF p (10 because that is the offset memory location) nothing happens.
I have attached a picture of my TopDesign.cysch.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi cood_4686241
Your code on the PSoC side is correct.
The bridge control panel is writing w 08 10 FF p which puts the FF byte (fourth command) in the 16th offset address; since the third command "10" stands for 16 in hex.
Please modify this to w 08 01 FF p and check the result.
Thanks,
Hari
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi cood_4686241
Your code on the PSoC side is correct.
The bridge control panel is writing w 08 10 FF p which puts the FF byte (fourth command) in the 16th offset address; since the third command "10" stands for 16 in hex.
Please modify this to w 08 01 FF p and check the result.
Thanks,
Hari
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey Hari,
Thanks, that worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just one more quick question about the UART video, I have this code which is working for the most part, I am seeing the echo of what I type in Tera term:
#include "project.h"
int main(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
char rxData;
UART_Start();
//UART_UartPutString( "Hello World!" );
for(;;)
{
rxData = UART_UartGetChar();
/*this line does not seem to be doing anything */
toupper(rxData);
UART_UartPutChar(rxData);
}
}
However, when I type in a lowercase character it just echoes the lowercase character and seems like it is essentially ignoring my toupper call. Any idea?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi cood_4686241,
Can you try replacing
toupper(rxData);
UART_UartPutChar(rxData);
with
UART_UartPutChar(toupper(rxData));
and let me know if it works?
Thanks and Regards,
Rakshith
Rakshith M B
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That worked, thanks! Do you know why it being seperated doesn't work?