1340 views|0 replies

3836

Posts

19

Resources
The OP
 

Implementation of Ethernet communication between TI C6678 DSP and PC [Copy link]

TI C6678 DSP supports multiple communication methods, and TCP/UDP communication through Ethernet port is one of them. This article mainly considers how to realize network communication and data transmission between DSP and PC, so the content is relatively simple, just making some modifications to TI's existing examples. As for using C6678 DSP to realize network applications and conduct network development, that is not the discussion of this article. For more information, please refer to the two technical manuals TI NDK User Guide and TI NDK API Reference Guide.

To import the sample project
, first make sure that the appropriate versions of MCSDK and NDK have been installed in the CCS directory. Regarding network communication, the two examples introduced by TI in Chapter 2, Example Applications, of the TI NDK User Guide can be found under MCSDK, for example, on my computer it is C:\ti\mcsdk_2_01_02_05\examples\ndk. The following contents are all modified based on the client project, so we import the client project in CCS here.

After importing, try to see if the compilation is successful. If the compilation fails, please modify the project according to the corresponding prompts. (It may be that the include location is set incorrectly.)

After successful compilation, connect the DSP development board and try to run the debugger (Run – Debug). If you encounter an error during the debugging process, please check the following items: (Note that we have not modified the source code of the project so far)

Did you reset the DSP development board before running? (Must do!)
Is the project running on Core0? (Cannot run on other Cores)
Has the DSP Boot mode been switched to I2C POST boot? (Cannot be in IBL NOR boot on image 0 (default) mode)

Modify client.c
After the initial debugging is successful, the project application cannot be executed correctly. We first need to make some modifications to the code.

First, change the LocalIPAddr, LocalIPMask, GatewayIP, and DNSServer near Line: 80 to the corresponding content of the network segment where the PC is located. Because my laboratory uses fixed IP, I directly assign a fixed IP address to the DSP (here I take 196.12.1.14 as an example). If the network segment uses dynamic IP, please refer to the relevant content of DHCP settings.

After changing the above content and recompiling and running, you can find the client program that can be run on the PC in C:\ti\ndk_2_21_01_38\packages\ti\ndk\winapps. Run in the console

send 196.12.1.14
recv 196.12.1.14 100
echoc 196.12.1.14 100
You can see the corresponding running results on the PC console and CCS console respectively.


Modify echo
Because what I want to realize is to use DSP composition controller to calculate the data sent from Ethernet and send the control rate back, so I am considering modifying the code related to echo in the project and inserting my own function for control rate calculation into it.

First, let's look at the client.c file. After the DSP initialization configuration is completed, the system will call the NetworkOpen() function. In this function, we see the following instruction:

hEcho = DaemonNew(SOCK_STREAMNC, 0, 7, dtask_tcp_echo, OS_TASKPRINORM, OS_TASKSTKNORM, 0, 3);

This instruction starts a process for echo response. The other parameters are ignored for now. We are mainly concerned with the dtask_tcp_echo parameter. This is a function handle, indicating that the response to echo is completed by the dtask_tcp_echo function. The specific implementation of this function is in the newservers.c file under C:\ti\ndk_2_21_01_38\packages\ti\ndk\tools\servers.

I once tried to modify the dtask_tcp_echo function in newservers.c directly, but after compiling and running, I did not get the expected results. I am not sure about the specific reason. But my solution is to change the original

hEcho = DaemonNew(SOCK_STREAMNC, 0, 7, dtask_tcp_echo, OS_TASKPRINORM, OS_TASKSTKNORM, 0, 3);

Comment out the command and replace it with your own definition:

myhEcho = DaemonNew(SOCK_STREAMNC, 0, 7, my_dtask_tcp_echo, OS_TASKPRINORM, OS_TASKSTKNORM, 0, 3);

Then, rewrite your own my_dtask_tcp_echo function by imitating the dtask_tcp_echo function in newservers.c. Insert your own calculation operation into the appropriate position of the function. At the same time, please note that TCP transmission is based on bytes, and certain data encapsulation and decapsulation operations must be performed before and after data transmission. (For related content, please refer to my other blog: Research on TI C6678 DSP and PC Matlab serial communication).

For testing, you can rewrite the echoc.c code in C:\ti\ndk_2_21_01_38\packages\ti\ndk\winapps and add your own calculation operations for testing. At the same time, please comment out the operation of checking the received data in echoc.c, because in the original function, if echoc.c finds that the received data is inconsistent with the sent data, it will terminate the communication and return an error message.

Ref.
TI Network Developer Kit (NDK) v2.21 Users Guide
TI Network Developer Kit (NDK) v2.21 API Reference Guide
TI E2E Comunity

This post is from DSP and ARM Processors
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list