I have a need to use both UART1 and UART2 at runtime with the DSPS peripheral mode application.
Basically in our design, we will have 2 devices attaching to UART1 and UART2 serial bus. With the current DSPS source code, how UART1 and UART2 being used was determined at compile time with the CFG_PRINTF_UART2 flag. If CFG_PRINTF_UART2 is set, then UART2 driver will be used. If not, UART1 will be used to send the message to the console.
Can UART1 or UART2 be selected and called upon to deliver messages to the attaching device (through the GPIO pin assignment)? I don't need to call upon both at any given time as long as they can be selected and called in sequential order.
Thanks,
--Khai
Device:
凯瑟你好,
谢谢你到达我们。我正在调查您的查询,并在找到解决方案时更新您。
Regards,
LC
我前进并插入了#define below in da1458x_config_basic.h to see if I can run DSPS as is so it will write the text out to Tera Term console sent from the phone.
#define CFG_PRINTF
#define CFG_PRINTF_UART2
I also changed the line in the user_sps_scheduler.c file in the uart_tx_callback() below from
uart_sps_write() to uart2_write() so it will call into the UART2 driver to write the message out.
static void uart_tx_callback(uint8_t res)
{
static uint8_t size=0;
uint8_t *periph_tx_ptr = NULL;
//function gets called from uart transmit isr or application when its not running
switch(res)
{
case UART_STATUS_OK:
//get data and pointer
size = user_periph_pull(&periph_tx_ptr, size);
休息;
case UART_STATUS_INIT:
size = user_buffer_read_address(&ble_to_periph_buffer, &periph_tx_ptr, TX_CALLBACK_SIZE);
休息;
默认:
ASSERT_ERROR(0); //error: callback called from unknown source
}
//if there is data available, send data over periph
if(size > 0)
{
UART2_WRITE(PERIPH_TX_PTR,SIZE,&UART_TX_CALLBALL);
//uart_sps_write(periph_tx_ptr, size, &uart_tx_callback);
返回;
}
//there is no data in the buffer so the callback is done
callbackbusy = false;
}
没有什么是没有写成控制台。FW不显示任何错误。如果您不介意,您可以尝试上面的代码,看看你是否可以看到相同的结果。
Thanks,
--Khai
凯瑟你好,
The latest issue in writing the data to the UART should've been due to the pin configuration. In order to see the configurations I would need to see the implementation. Will that be feasible to upload your project for reviewing.
另外,是基于SDK5.0.2还是SDK5.0.3的DSP?你能崇拜这个吗?
Regards,
LC
Sure. I am using SDK 5.04.
Thanks,
--Khai
凯瑟你好,
您是否可以验证此应用程序使用哪种devkit?
And FYI, the DSPS you are working on (if I am referring to the right one) is based on our SDK5.0.3 version.
Regards,
LC
Basic Kit
Khai,
How are you connecting the UART to the Console. Is it via on-board USB or you are using additional hardware to do that?
Regards,
Leepeng
我正在使用SPI引脚配置J4连接器的第二个右侧的基本套件上,使用P0_4跳转,因此我可以获得控制台打印(使用此设置,因为我正在测试SPI闪存读/写和打印到控制台。我相信SPI_FLASH正在使用UART2进行控制台打印。
Thanks,
--Khai
Khai,
So in the code, I see that you are enabling both the uarts (UART1 and UART2). Are you trying to write using both the uarts via the USB connection?
You can use only either of the UARTs via onboard USB and in order to use both of them simultaneously you need another FTDI converter so that you can connect to USB.
Can you confirm if you need only the UART2 or UART1 to work for your 2nd question.
Regards,
LC
As you can see what I was trying to do. I tried to use uart2_write() rather than uart_sps_write() to write the message to the console and it's not working. I was just testing to see if I can see uart2_write output to the console with my setup. Essentially, I need both UART1 and UART2 to work in our design.
One of the below 3 cases can happen at any given time.
1. message to UART1
2. message to UART2
3. message to both UARTs (if I can't send to both in a single write call, then it's ok I send them sequentially)
By simply replacing uart_sps_write() with uart2_write(), why doesn't that work (not seeing the console print of the text message) since I have configured the GPIO port and pins assignment for UART2. Right now, I am simply just testing UART2 only.
When this is all said and done, I will need to hook up another FTDI cable to see console output to both UART1 and UART2. I do have the cable but unable to get it to work following instructions from one of the Doc. If you can tell me how, I would be greatly appreciated. I will need to do this sooner or later to check the connection.
Thanks,
--Khai
凯瑟你好,
I have reviewed the project and the uart2 is working. So here is the setting you have to make for using the uart2 to write to a serial terminal.
为了连接UART2,您需要将port0_4和port0_5分配给UART端口和PIN in user_periph_setup.h,以便引脚FTDI引脚连接到UART2。
Note:Make sure that you disable these same pins for UART1 as there will be assignment collisions.
And, on the Basic DevKit, configure the baord in UART configuration.
Use uart2_write() function to write data to the terminal.
Regards,
LC
嗨LC,
If you made changes to my project regarding GPIO setting, please send me the diff of what you did to get UART2 to work. It's hard for me to follow your instructions in the respond message.
But then doing what you suggested will only enable UART2 write and disable UART1. My goal is to be able to send messages to either UART1, UART2 or both at any given time? Can both UART1 and UART2 be configured so they can be used at run time? That was my original question. I need to be able to do:
1. message to UART1 from phone app
2. message to UART2 from phone app
3. message to both UARTs from phone app (if I can't send to both in a single write call, then it's ok I send them sequentially)
Thanks,
--Khai
凯瑟你好,
I am looking in your query about using both the UARTs simultaneously. I have reviewed the UART2 question of yours first to see why the UART2 isn't working. I am uploading the project and the diff to this thread for you reference. Having said that, I am exploring the simultaneous usage case and will update you.
Note:The modifications can be identified with a commnet "CHANGES" before the statements.
Regards,
LC
嗨LC,
Thanks for helping in finding the solution for me. Do you have an update on the topic yet?
Thanks,
--Khai
凯瑟你好,
Yes, you can use both the UARTs simultaneously. All you have to do is define the "CFG_PRINTF_UART2“正如你现在所做的那样。引脚定义和预订都是好的。UART1on(0_4, 0_5)andUART2on(1_2, 1_3).
However, forUART1您需要使用该功能uart_write()and forUART2use the functionuart2_write()as defined in the file"uart.h"
您可以使用UART1的Onbord FTDI连接和UART2的外部FTDI。
如果您对此有任何疑问,请告诉我。
Regards,
LC
Ok, nice. I will try it out tomorrow and let you know. Did you try it on my DSPS project I sent you? Also, how do I connect the external FTDI cable to the J4 header? If you can walk me thru how to jump the J4 header for writing console output for UART1 and UART2, that would be great.
Thanks,
--Khai
Sure...
Yes, I did the test using the project you have sent us.
So, here is how the connections will look like on the J4:
Header_pin11... port0_pin4 (UTX) connected to FTDI T_RxD (as per the schematics)
header_pin13 ... port0_pin5(urx)连接到ftdi t_txd(根据原理图)
Header_pin5... port1_pin3 (assigned to UTX) connected to FTDI T_RXD (of another BASIC kit)
Header_pin6... port1_pin2 (assigned to URX) connected to FTDI T_TXD (of another BASIC kit)
注意:如果您没有其他基本套件,则需要使用任何兼容的FTDI转换器
在连接和断开事件时,我尝试将一些数据写入UART和UART2。
Regards,
LC
嗨LC,
So do I remove all the function calls referencing in uart_sps.h to calls in uart.h in user_sps_scheduler.c? What is the difference between uart_sps.c and uart.c? Why didn't DSPS simply use uart.c function calls for console read/write but instead created its own uart_sps.c?
Thanks,
--Khai
嗨LC,
I just have the time to start looking at connecting external FTDI cable for a second UART output. I have the FTDI cable as described in UM-B--38 Doc section 8.1 Hardware setup fro the Basic Kit.
我每张附图订购了这个确切的电缆。但是,不,我正在看它,我仍然无法弄清楚跳出J4标题以获得UART1和UART2控制台输出。我的问题是:
1. My board is currently jumped based on UART mode per the schematic next to the J4 header. This allows me to write console output using UART1 when running the DSPS peripheral FW. Now, I have added UART2 GPIO configuration with UART2 on (1_2, 1_3). With the external FTDI cable I have, how can I use this cable to output UART2 data?
2. The FTDI converter cable has 6 wires. Per your instruction above,
Header_pin5... port1_pin3 (assigned to UTX) connected to FTDI T_RXD (of another BASIC kit)
Header_pin6... port1_pin2 (assigned to URX) connected to FTDI T_TXD (of another BASIC kit)
Do I just connect 2 wires out of 6 FTDI Cable Rx (yellow wire) to pin 5, and Tx (orange wire) to pin 6 of the Basic Kit? I attached a picture of the cable connection for clarity.
Thanks,
--Khai
嗨LC,
请您回复我的问题。直到我再次得到你的帮助,我暂时陷入困境。
Thanks,
--Khai
凯瑟你好,
For you first question, the DSPS is a bluetooth version of the serial data transfer. So, it includes functions like uart_sps_write() to take the data in and send it over the bluetooth or receive data over bluetooth interface. If you look at the implementation, uart_write() and uart_sps_write() has similar implementation, only the former is writing to the Peripheral UART and the later is sending data over BLE.
You do not need to replace the uart_sps_write() with uart_write(). Instead, if you wish to write the data to uart or uart2 peripheral, just implement a call back function for the respective uart.
Regards,
LC
凯瑟你好,
1. My board is currently jumped based on UART mode per the schematic next to the J4 header. This allows me to write console output using UART1 when running the DSPS peripheral FW. Now, I have added UART2 GPIO configuration with UART2 on (1_2, 1_3). With the external FTDI cable I have, how can I use this cable to output UART2 data?
First, with the configuration printed on the PCB you can use the UART1 to write data to the serial terminal on your PC/MAC via the Mini-USB connected to the DevKit.
Now you can use the FTDI cable to connect to the UART2 on DevKit and the other end of the cable to your PC/MAC. Open 2 separate instances of the terminal to connection to each of the ports and you'll be able to communicate over both UART1 and UART2.
2. The FTDI converter cable has 6 wires. Per your instruction above,
Header_pin5... port1_pin3 (assigned to UTX) connected to FTDI T_RXD (of another BASIC kit)
Header_pin6... port1_pin2 (assigned to URX) connected to FTDI T_TXD (of another BASIC kit)
Do I just connect 2 wires out of 6 FTDI Cable Rx (yellow wire) to pin 5, and Tx (orange wire) to pin 6 of the Basic Kit? I attached a picture of the cable connection for clarity.
For the connection, you will need the Transmit, Receive and GND to be connected to the FTDI converter. Please make sure a common GND is connnected, otherwise there will be no communication. Coming to the transmit and receive, the naming convention can be sometimes confusing, so just connect the Tx on Basic Kit to Rx on FTDI and Rx on Basic Kit to Tx on FTDI. If you see no communication just swap the Tx and Rx wires.
这应该解决哟ur issues. Please let me know if you have any more questions. Again, thanks for your patience.
Best,
LC
hi LC,
谢谢你的提示。与外部FTDI电缆TX和RX线的物理连接现在连接到J4 GPIO引脚。我现在能够通过一个问题来获得UART打印到控制台。UART1输出到TERATERM现在已损坏,UART2输出很好。UART1是板载串行输出,而UART2是FTDI连接。
如果你不介意的话,请使用我原来的项目sample I sent you to start with. Then apply this new user_sps_scheduler.c file attached to the project. Build the code and load it to the the 580 Basic Kit. Run the DSPS Android app on the phone and send it some text messages. You will see that UART1 output (uart_sps_write()) is corrupted while UART2 output (uart2_write()) is fine.
I created a callback function uart_both_tx_callback() to per your suggestion (attached code) to write to both uart1 and uart2. This is where you might be able to help why that is. The function is pasted below for discussion:
静态void UART_BOTH_TX_CALLBALL(UINT8_T RES)
{
static uint8_t size=0;
uint8_t *periph_tx_ptr = NULL;
//function gets called from uart transmit isr or application when its not running
switch(res)
{
case UART_STATUS_OK:
//get data and pointer
size = user_periph_pull(&periph_tx_ptr, size);
休息;
case UART_STATUS_INIT:
size = user_buffer_read_address(&ble_to_periph_buffer, &periph_tx_ptr, TX_CALLBACK_SIZE);
休息;
默认:
ASSERT_ERROR(0); //error: callback called from unknown source
}
//if there is data available, send data over periph
if(size > 0)
{
uart_sps_write(periph_tx_ptr, size, NULL);
UART2_WRITE(PERIPH_TX_PTR,SIZE,&UART_BOTH_TX_CALLBALL);
}
//there is no data in the buffer so the callback is done
both_tx_callbackbusy = false;
}
正如您所看到的,它与UART_TX_CALLBACK()非常相同。现在我从外围FIFO读出邮件后,我拨打了UART_SPS_WRITE()和UART2_WRITE()并提供相同的消息指针和大小。但是,对于UART_SPS_WRITE(),我将它传递一个null回调,以防止回调在uart2_write()下次左右再次调用,我用一个有效的回调函数名称uart_both_tx_callback。
I'll zip up the entire project so you can just simply launch it and help me check it out.
Thank you and very much appreciate it.
--Khai
By the way, I open up to TeraTerm for two UART outputs.
连接了TERA终端输出的屏幕捕获。COM5(板载串行连接)是UART1和COM4(外部FTDI电缆连接)是UART2
凯瑟你好,
I am looking into your project to run it. Now, I am confused with your screen capture. Looking at the Teraterm output, that seems to be working with both UART1 and UART2 right. Is the issue resolved or it still stands?
Best,
LC
它不完全打印文本。的identical text must be printed as I sent the same text to both UARTs
凯瑟你好,
我在这里的基本devkit上运行了你的项目,它看起来很正常。我没有对您的项目进行任何更改,我刚刚编译并运行相同的代码。
The only change from your setup to mine is that, I am using another DevKit instead of the FTDI converter on UART2. As per your observations, UART2 does not have any issue on your side right?
I am not sure what is wrong on your side in this context since it is working on my side. I would like to ask you to verify your setup once more to make sure everythings in the right place.
I am sending you my captures...
Best,
LC
嗨LC,
I got it working now by now simply providing the callback function name to uart_sps_write() and NULL to uart2_write() as shown below which was the opposite to the previous scenario. I don't understand how it works now compared to what I have previously. If you can explain why, that would be great.
if(size > 0)
{
uart_sps_write(periph_tx_ptr, size, &uart_both_tx_callback);
UART2_WRITE(PERIPH_TX_PTR,SIZE,NULL);
}
凯瑟你好,
Unfortunately, I couldn't tell the difference since it is working for me the both ways.
Best,
LC
算了。情况下关闭。Thank you for your patient.
You are welcome. Please let us know if you come across any issues in the future.
Best,
LC
嗨LC,
The UART transaction size is specified in TX_CALLBACK_SIZE = 16 bytes. Can this size be much larger? What's the reason for such a small burst of data per transfer?
Reason I ask is that I need to transfer firmware to an external device attaching to UART1 and UART2 for them to boot. So the device FW is 20K bytes.
Thanks,
--Khai
嗨LC,
I am experiencing strange behaviors with this code I have that uses both UART1 and UART2. Everything works fine as implemented in the FW when the FW is loaded to SysRAM directly from Keil debugger. You have tried and run this code yourself and verified that it worked.
当我开始使用SmartSnippets flash the same FW to SPI Flash on the basic kit and boot from flash, upon power up, the FW doesn't seem to be downloaded from Flash to SysRAM correctly. Reason I said that was that the phone app won't be able to find its present. Below is the step to reproduce:
1. Place the jumpers on the J4 header of the Basic Kit to configure it for SPI mode
2. Use SmartSnippets to flash the DA FW you have from me to the Basic Kit SPI Flash
3. Connect the external FTDI cable Tx/Rx to UART2 pins P1_2 and P1_3 (swap it around if you don't see the text in the console)
4. Launch 2 Tera Terminals, one for the onboard serial connection and the other for the external FTDI cable connection. The onboard connection is UART1 and FTDI is UART2
5. Cycle power the basic Kit if it's currently plugged in
6. Launch the DSPS phone app on the phone. The app should fail to find the Basic Kit with name NearEye (I changed this name to reflect for our intended HW)
However, if the FTDI cable for UART2 connection were to be removed from the board (remove the Tx/Rx pins), recycle power on the board will allow the phone app to find it again. Now reconnect the FTDI cable to the board Tx/Rx pins will allow both UART1 and UART2 to function as intended.
If it didn't happen for you right away, please repeat steps 3-6 again. It looks as if configuring UART2 in the DA FW to be used caused loading from Flash to fail.
希望你能重现这个问题。
Thank you in advance,
--Khai
凯瑟你好,
TheTX_CALLBACK_SIZEis configured based on the Hardware FIFO on the UART and 16 Bytes is the maximum value for it.
对于你的第二个问题,我将在建议的情况下在董事会上尝试。不幸的是,我现在无法访问基本的devkit。我会尝试一下并回复你。
Best,
LC
附件是压缩文件for the source code for your convenience in case you didn't keep the previous project in your system.
凯瑟你好,
I have tried running the project from the flash as you have suggested. Here I have a clarification to make, how did you arrange the jumpers J4 and J6 of the DevKit. When the board is configured in the SPI mode, you are essentially disconnecting the UART1. Make sure you have connected the UART1 via J4_11, J4_12 and the pins J6_1, J4_13 and J4_14 should be connnected via a 3 pin jumper instead of the 2 pin ones. This way you will be able to use the UART as well along with the SPI. However, I would suggest to be cautious since you are essentail connecting the peripherals as well. Instead you can also use a second external FTDI converter if that is more flexible.
Coming to the project, I have seen some issues from your recent project you have uploaded. But, the previous version of the project is functioning normally from the flash as well. So I would recommend you to review your project for any changes that can conflict with the normal operation.
Note: There was also a function naming/referencing error in your latest project version. Please check these before uploading the project.
Best,
LC
嗨LC,
Thanks for looking into my issue. You mentioned J6 jumpers. There is no J6 that I can find in the Basic DevKit. Attached (\v5.1.50.2.org\BasicKit-SPI-UART1-UART2.jpg) is a snapshot of the board that's currently jumped for UART1 and UART2 with SPI. As you can see, the FTDI black, orange and yellow wires are external UART2 connection. With this jumped configurations, I was able to get SPI and UART1 no problem. UART2 was added with the FTDI wires at the top of the J4 header. Without the FTDI wires, booting from flash or load directly to SysRAM worked fine as I explained in my step above.
Regarding the differences between my current project vs the previous one, GPIO ports/pins are assigned the same. The only difference is that the current project was added with some SPI flash wrapper code for our own application development.
是的,您是在项目命名/参考错误中正确的。对于那个很抱歉。我已经修复了错误,这是最新的。
Thanks,
--Khai
File is over 10MB with image. I enclosed the DevKit image here.
凯瑟你好,
The Jumper J6 is the one with 2 pins on the side of J4. This is clearly visible in your DevKit setup image as well and I am uploading the same with the highlighted part of J6.
注意:只需要3个引脚跳线,以便将UART RX与FTDI和MISO连接。直到您需要此PIN的时间,即使没有此,您的设置也是如此。
我有再次运行您的最新项目,我没有ticed that there are issue. But to emphasize again, I have also run your previous version of the project with the same setup which is working well. I strongly beleive that some changes you have done so far might be conflicting with the application. I recommend you to refer to your previos version and see if you face any issues. If you don't see any issues, then proceed from there with step by step changes to check which addition is causing this problem.
Best,
LC
Thanks LC.
I didn't the SPI pins connection is called J6
If you don't mind, can you zip up my previous project you have so I can do comparison?
Did you connect J4 and J6 with a 3 pin jumper to test my project?
Thanks,
--Khai
Can you take a snapshot of the board you have so i can compare?
凯瑟你好,
因此,建立J4和J6以适应这种不同的配置。我正在上传你以前的项目。您可以尝试使用与连接设置进行测试,这是我的工作。我已经用3个引脚连接器测试了这个项目,除非您正在从我认为您正在做的终端发送数据,否则这不会影响。所以请使用您当前的设置。
Best,
LC
LC,
I tested the working project you sent back. The result is the same. DSPS App failed to discover the device (NearEye) when booted from flash but it's discovered OK when uploaded to RAM from Keil.
Thanks,
--Khai
凯瑟你好,
I have downloaded the exact same copy I have sent you, built the code and using SmartSnippets SPI Flash Programmer burned the image to Flash. I have 2 Tera Term terminals opened for the respective COM ports. After programming the flash, just did a board reset and I am able to see the Device in DSPS application and able to send the data to the device which is being written to the Tera Term terminals via UART1 and UART2.
I am not sure what is going wrong on your side. I am using the same exact configuration that you have shown previously in "BasicKit-SPI-UART1-UART2" image. Can you put up the DevKit, SmartSnippets and Terminal Output images. So that, I can review if there is anything wrong.
Best,
LC
Thanks for running the test again, LC.
I would like to say the problem of the DSPS App discovering the device is intermittent. The app was able to detect it the first couple of times. Every time it detected the device, I don't bother sending it text (I know it will work). I simply recycle power the board (pull the USB cable from it rather than reset) and launch the phone app to detect it again. You will find that the app will not see the device anymore. Please try it for me. I am not sure what caused the intermittent.
Questions:
1. Did you use FTDI external cable for the other UART connection?
2. Did you jump J4 and J6 the same as my setup?
3. Did you set Tera Terminal baud to 115200 and Flow Control to Xon/Xoff?
Thanks,
--Khai
凯瑟你好,
所以,我明白你是电力骑行,但必须注意一些步骤,以确保电动过程是正确的。
1. When the board is powered down, there should not be some external power source connected to the pins like the FTDI converter connected to the UART2 which can leave some residue on the pins and can be a problem
2. When you power up the board, it is recommended to do a RESET to ensure proper input voltage to the processor which is required for the boot process to be right.
Without the Hardware Reset we cannot ensure that the boot process will be right after the system is powered up. It works most of the times, but not always. If you are powering out of a battery that can provide the required voltage at the requried pace, then it should work without reset nearly all the times.
请尝试这些步骤,看看问题是否已解决。
Best,
LC
好的。重置板后power cycle with the FTDI cable connected seem to work.
Questions:
1.按下复位按钮是否从闪光到RAM重新下载FW?
2.是否有软件API可以从手机应用程序重置电路板?
Thanks,
--Khai
凯瑟你好,
1. Yes, it does as if the system is being restarted but is more controlled and the input supply is stable this way.
2. No, since the system doesnot start running until there is a reset done, you cannot connect to the device. So you cannot issue an external command without connecting.
Best,
LC
好的。then tell me how to do a software reset in the FW after it's been successfully loaded to sysRAM. I will create a protocol interface from the phone app to reset the board by sending it a reset command.
Thanks,
--Khai
Pages