Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
HDTiwari
Level 2
Level 2
10 replies posted 5 questions asked First solution authored

Respected fellow designers,

I am trying to interface HC-05 bluetooth module with XMC4700 relax kit.

I have the TX and RX running in arduino IDE without any issues.

However, I wish to replicate the same using Modus tool box.

I am able to transmit through the HC-05 module and see the output in my mobile.

However, I am unable to get the receiver working.

I have tried using RX FIFO but could not get any output.

I have shared my project.

Kindly suggest  some method to get  TX and RX working through modus toolbox.

Thank you

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
HDTiwari
Level 2
Level 2
10 replies posted 5 questions asked First solution authored

Respected Pradeep Sir,

I got it working using DAVE app.

Code********

/*
* main.c
*
* Created on: 2023 Apr 05 22:32:55
* Author: mj
*/

 


#include "DAVE.h" //Declarations from DAVE Code Generation (includes SFR declaration)

/**

* @brief main() - Application entry point
*
* <b>Details of function</b><br>
* This routine is the application entry point. It is invoked by the device startup code. It is responsible for
* invoking the APP initialization dispatcher routine - DAVE_Init() and hosting the place-holder for user application
* code.
*/

#define msg_length 8

int main(void)
{
DAVE_STATUS_t status;
uint8_t Send_Data[] = "\r\nInFiNeOn\r\n";
uint8_t Rec_Data[msg_length];
uint8_t terminator[] = "#";
uint8_t terminator2[] = "\r\n";
uint8_t index = 0;

status = DAVE_Init(); /* Initialization of DAVE APPs */

if (status != DAVE_STATUS_SUCCESS)
{
/* Placeholder for error handler code. The while loop below can be replaced with an user error handler. */
XMC_DEBUG("DAVE APPs initialization failed\n");

while(1U)
{

}
}

/* Placeholder for user application code. The while loop below can be replaced with user application code. */
while(1U)
{
/*Transmit the string "Infineon" */
index = 0;
while(Send_Data[index] != 0)
{
UART_TransmitWord(&UART_0,Send_Data[index]);
index++;

/*Wait for transmit buffer interrupt to fill it again with remaining data */
while((UART_GetTXFIFOStatus(&UART_0) & XMC_USIC_CH_TXFIFO_EVENT_STANDARD) == 0);
UART_ClearTXFIFOStatus(&UART_0, XMC_USIC_CH_TXFIFO_EVENT_STANDARD);
}

/* Receive 10 bytes input */
index = 0;
/* Wait till 10 bytes are received */
while (index < msg_length)
{
if (!UART_IsRXFIFOEmpty (&UART_0))
{
Rec_Data[index] = UART_GetReceivedWord(&UART_0);
UART_TransmitWord(&UART_0,Rec_Data[index]);
index++;
}
}


/*Transmit the received data */
index = 0;
while( index < msg_length )
{
UART_TransmitWord(&UART_0,Rec_Data[index]);
index++;

/*Wait for transmit buffer interrupt to fill it again with remaining data */
while ((UART_GetTXFIFOStatus (&UART_0) & XMC_USIC_CH_TXFIFO_EVENT_STANDARD) == 0);
UART_ClearTXFIFOStatus(&UART_0, XMC_USIC_CH_TXFIFO_EVENT_STANDARD);
}
UART_TransmitWord(&UART_0,terminator[0]);
UART_ClearRXFIFOStatus(&UART_0, XMC_USIC_CH_RXFIFO_EVENT_STANDARD);

}
}

****** Pin configuration

RX as 2.15

TX as 2.14

 

Thank you very much for your support.

I am attaching the code for reference of all.

With regards.

 

View solution in original post

0 Likes
15 Replies
Pradeep_PN
Moderator
Moderator
Moderator
250 sign-ins 100 solutions authored 25 likes received

Hi @HDTiwari ,

Greetings from Infineon.

Just to confirm whether you made the  connection properly as for the first communication between the pc and XMC you are using USIC0_CH0 where there is already an USB-UART bridge so no necessity of external wire connection but for the communication between the XMC and the HC-05 you are using the USIC1_CH0 where port  2_14 and 2_15 are TXD and RXD there needs to be an jumper wire connections from 2_14 to HC-05 and HC-05 to 2_15.

Coming to code(main.c) there needs to change in the enabling of interrupts as you have Intialised USIC1_CH0 but enabling USIC1_CH1 interrupts. So look into the interrupt part and enable the system timer for communication.

Hope this helps and kindly let me know if you need any further information.

Best Regards
Pradeep.

0 Likes
lock attach
Attachments are accessible only for community members.

Respected PPN,

Thanks for the quick and prompt reply.

As you mentioned correctly, in the code I am using both USIC0_CH0 (DEBUG) as well as USIC1_CH0 for HC05. I have cross checked the connection by using a basic uart TX RX code using XMC4700 relax kit and HC05 using Arduino ide. The trick was to initialize Serial as Serial1 and everything happened automatically. For reference I have attached the Aurdino sketch and the communication screenshot.

This code will eventually become a part of state machine where the uart will be polled at certain instances only. Hence repetitive tx and thereby using timer would be futile.

I have corrected the initialization of "USIC1_CH0" and I have uploaded my project again. Kindly help by going through it. I am still not able to get the communication working.

"So look into the interrupt part and enable the system timer for communication." - Kindly suggest the link to material for XMC4700 regarding the same.

On a side note: Which tool chain will be preferred by Infineon in future DAVE or Modus Toolbox.

Thank you for the reply once again.

With regards

 

0 Likes
Pradeep_PN
Moderator
Moderator
Moderator
250 sign-ins 100 solutions authored 25 likes received

Hi @HDTiwari ,

Greetings from Infineon.

We support  Modus Toolbox in future so we recommend you to use Modus Toolbox.

Regarding the establishment of communication between the XMC and the HC-05 below are some code examples which you can refer.

Please refer to this link

https://github.com/Infineon/mtb-example-xmc-uart-transmit-receive-fifo-interrupts

https://github.com/Infineon/mtb-example-xmc-uart-transmit

Hope this helps and kindly let me know if you need any further information.

Best Regards 

Pradeep.

 

 

 

0 Likes

Respected ppn,

I have already tried using "https://github.com/Infineon/mtb-example-xmc-uart-transmit-receive-fifo-interrupts".

As explained if we connect pin6.3 and 6.4 in relax kit the LED turns on. 

However, if I connect 6.3 RXD with TXD of HC05 and 6.4 TXD with RXD of  HC05, I do not see any output in connected mobile app.

The second example "https://github.com/Infineon/mtb-example-xmc-uart-transmit" is just TX and no RX.

I will try re-assigning the pins to 2.15 and 2.14 in relax kit and try to get response.

I however humbly request the team to provide examples such that the arduino pins can be used in modus toolbox especially with basic arduino applications like uart.

Thank you,

with regards

0 Likes
Pradeep_PN
Moderator
Moderator
Moderator
250 sign-ins 100 solutions authored 25 likes received

Hi @HDTiwari ,

Greetings from Infineon.
The above code example is based on loop back mode for loop backing data that was received from the transmitter to the transmitter side we are doing this by hardwire connnection between the pin 6.3 ad pin 6.4.
As you are using pin 6.3 and pin 6.4 you need to update the device configurator where you need to assign pin 6.3 to RXD and pin 6.4 to TXD at the USIC configuration,even after the upgrading the device configurator
there is problem in establishing the communication once you need to check at the HC05 end.
Regarding the code example about the arduino pins can be used in modus toolbox at present we don't have and we are considering your suggestion.
Thanks and Regards
Pradeep.

0 Likes
lock attach
Attachments are accessible only for community members.

Respected ppn,

I think we are one step closer to the target.

I used the https://github.com/Infineon/mtb-example-xmc-uart-transmit-receive-fifo-interrupts example.
In the example sited above USIC0 is used and is connected to pins 6.4 and 6.4. I configured USIC1 identical to USIC0 re-assigning the pins to 2.15 and 2.14 in relax kit, checked the loopback. It worked fine.

Then I connected the HC05 to Pins 2.15 and 2.14. Initially there was no response. 

In the sample code the data is sent and received only once.

Hence, I tried to clear the data and send custom data in while loop.

Now I was able to see the output in in mobile app through HC05.

However, the first character of data was not received completely and with every transmit same text is repeated. Kindly see the image attached.

Similarly, there is still no RX.

Using the https://github.com/Infineon/mtb-example-xmc-uart-transmit exampleI tried checking the read operation using of debug port so that later I can change the pins to 2.15 and 2.14.

I saw the solution provided in https://community.infineon.com/t5/XMC/XMC1302-T038X0032-UART-can-send-data-but-cannot-receive-data/t... however it is not working for me. I am attaching both the projects. Kindly have a look and suggest. If the rx can be made to work using debug pins in second project that is based on transmit example, I will make the modification to try with another channel for Arduino compatible pins 2.14 and 2.15. 

Kindly help.

With regards

0 Likes
Pradeep_PN
Moderator
Moderator
Moderator
250 sign-ins 100 solutions authored 25 likes received

Hi @HDTiwari ,

Greetings from Infineon.

I went through you code and found that you haven't declared any USIC channel for 'usr_uart_hc05_HW' in the device configurator.
So declare the 'usr_uart_hc05_HW' in the device configurator (ie name the USIC channel you are using to communicate between XMC and HC05 as 'usr_uart_hc05')and then try building it. 

Best Regards
Pradeep.

0 Likes

Respected ppn,

The RX fifo project has the USIC0_CH1 declared as "usr_uart_hc05" in device configurator. While "UART_Transmit_v01" project does not use usr_uart_hc05 declaration. Kindly let me know which project are you referring to.

As mentioned earlier Using the https://github.com/Infineon/mtb-example-xmc-uart-transmit example I tried checking the read operation using debug port so that later I can change the pins to 2.15 and 2.14.

I saw the solution provided in https://community.infineon.com/t5/XMC/XMC1302-T038X0032-UART-can-send-data-but-cannot-receive-data/t... however it is not working for me. I had attached the project earlier. Kindly have a look and suggest. If the rx can be made to work using debug pins in second project that is based on transmit example, I will make the modification to try with another channel for Arduino compatible pins 2.14 and 2.15. 

Kindly help.

With regards

0 Likes
Pradeep_PN
Moderator
Moderator
Moderator
250 sign-ins 100 solutions authored 25 likes received

Hi @HDTiwari ,

Greetings from Infineon.

The project you shared UART_Transmit_Receive_FIFO_Interrupts_v02 ,I imported the project into my MTB and found you haven't declared    USIC0_CH1 so can you please  share your correct project once again.

Best Regards,
Pradeep.

0 Likes
lock attach
Attachments are accessible only for community members.

Respected ppn,

kindly find the zip file of the project.

Kindly let  me know if there is some specific way to zip the files.

I am straight away making the zip file of the project folder.

Thank you for quick and prompt response.

I really appreciate it

0 Likes
lock attach
Attachments are accessible only for community members.

Respected Pradeep Sir,

Thank you for quick reply.

I have created a new workspace. I recreated the entire project. I have compiled and programmed the XMC4700 with it.

In the example sited above USIC0 is used and is connected to pins 6.4 and 6.4. I configured USIC1 identical to USIC0 re-assigning the pins to 2.15 and 2.14 in relax kit, checked the loopback. It worked fine.

Then I connected the HC05 to Pins 2.15 and 2.14. Initially there was no response. 

In the sample code the data is sent and received only once.

Hence, I tried to clear the data and send custom data in while loop.

Now I was able to see the output in in mobile app through HC05.

However, the first character of data was not received completely and with every transmit same text is repeated. Kindly see the image attached.

Similarly, there is still no RX.

Today I have shared the entire workspace.

Kindly let me know if this is ok.

Thank you once again for the quick response.

With regards

0 Likes
lock attach
Attachments are accessible only for community members.

Respected Pradeep Sir,

Thank you for quick reply.

USIC0_CH1 is declared by default as "CYBSP_DEBUG_UART" when we create a new application based on example given in modus toolbox. 

In the example sited above USIC0_CH1 is used and is connected to pins 6.4 and 6.4. I configured USIC1_CH0 identical to USIC0_CH1 re-assigning the pins to 2.15 and 2.14 in relax kit, checked the loopback. It worked fine.

Then I connected the HC05 to Pins 2.15 and 2.14. Initially there was no response. 

In the sample code the data is sent and received only once.

Hence, I tried to clear the data and send custom data in while loop.

Now I was able to see the output in in mobile app through HC05.

However, the first character of data was not received completely and with every transmit same text is repeated. Kindly see the image attached.

Similarly, there is still no RX.

I have shared the entire workspace.

Kindly open the workspace after extraction rather then importing the project in MTB

Kindly let me know if this is ok.

Thank you once again for the quick response.

With regards

0 Likes

Respected Pradeep Sir,

USIC0_CH1 is declared by default as "CYBSP_DEBUG_UART" when we create a new application based on example given in modus toolbox. 

I have shared the entire workspace in my reply on "Mar 25, 2023 09:05 PM" given below.

Kindly open the workspace after extraction rather then importing the project in MTB

Kindly let me know if this is ok.

Thank you once again for the quick response.

With regards

0 Likes
Pradeep_PN
Moderator
Moderator
Moderator
250 sign-ins 100 solutions authored 25 likes received

Hi @HDTiwari ,

Greetings from Infineon.

After extracting the project   I couldn't find the updated   .modus  file (DEVICE CONFIGURATOR).
In the above project you shared the USIC1_CH0 is not declared so don't share the entire workspace just share the project that  you are using to communicate with HC-O5.
Please Right click on the project in the drop down select the properties there you can see the location of the folder.
Can you please share the folder that the above path is pointing to.

Best Regards
Pradeep.

0 Likes
lock attach
Attachments are accessible only for community members.
HDTiwari
Level 2
Level 2
10 replies posted 5 questions asked First solution authored

Respected Pradeep Sir,

I got it working using DAVE app.

Code********

/*
* main.c
*
* Created on: 2023 Apr 05 22:32:55
* Author: mj
*/

 


#include "DAVE.h" //Declarations from DAVE Code Generation (includes SFR declaration)

/**

* @brief main() - Application entry point
*
* <b>Details of function</b><br>
* This routine is the application entry point. It is invoked by the device startup code. It is responsible for
* invoking the APP initialization dispatcher routine - DAVE_Init() and hosting the place-holder for user application
* code.
*/

#define msg_length 8

int main(void)
{
DAVE_STATUS_t status;
uint8_t Send_Data[] = "\r\nInFiNeOn\r\n";
uint8_t Rec_Data[msg_length];
uint8_t terminator[] = "#";
uint8_t terminator2[] = "\r\n";
uint8_t index = 0;

status = DAVE_Init(); /* Initialization of DAVE APPs */

if (status != DAVE_STATUS_SUCCESS)
{
/* Placeholder for error handler code. The while loop below can be replaced with an user error handler. */
XMC_DEBUG("DAVE APPs initialization failed\n");

while(1U)
{

}
}

/* Placeholder for user application code. The while loop below can be replaced with user application code. */
while(1U)
{
/*Transmit the string "Infineon" */
index = 0;
while(Send_Data[index] != 0)
{
UART_TransmitWord(&UART_0,Send_Data[index]);
index++;

/*Wait for transmit buffer interrupt to fill it again with remaining data */
while((UART_GetTXFIFOStatus(&UART_0) & XMC_USIC_CH_TXFIFO_EVENT_STANDARD) == 0);
UART_ClearTXFIFOStatus(&UART_0, XMC_USIC_CH_TXFIFO_EVENT_STANDARD);
}

/* Receive 10 bytes input */
index = 0;
/* Wait till 10 bytes are received */
while (index < msg_length)
{
if (!UART_IsRXFIFOEmpty (&UART_0))
{
Rec_Data[index] = UART_GetReceivedWord(&UART_0);
UART_TransmitWord(&UART_0,Rec_Data[index]);
index++;
}
}


/*Transmit the received data */
index = 0;
while( index < msg_length )
{
UART_TransmitWord(&UART_0,Rec_Data[index]);
index++;

/*Wait for transmit buffer interrupt to fill it again with remaining data */
while ((UART_GetTXFIFOStatus (&UART_0) & XMC_USIC_CH_TXFIFO_EVENT_STANDARD) == 0);
UART_ClearTXFIFOStatus(&UART_0, XMC_USIC_CH_TXFIFO_EVENT_STANDARD);
}
UART_TransmitWord(&UART_0,terminator[0]);
UART_ClearRXFIFOStatus(&UART_0, XMC_USIC_CH_RXFIFO_EVENT_STANDARD);

}
}

****** Pin configuration

RX as 2.15

TX as 2.14

 

Thank you very much for your support.

I am attaching the code for reference of all.

With regards.

 

0 Likes