<< Chapter < Page Chapter >> Page >
The core file provides two macros, READSER and WRITSER, for communicating with a PC via the serial port. One can create graphical user interfaces in MATLAB to control the DSP in real time.

Using the serial port

The core file supports the serial port installed on the TI TMS320C54x DSP. The serial port on the EVM is connected with acable to COM2 on the PC. Before jumping to your code, the core file initializes the EVM's serial port to 38,400 bits persecond (bps) with no parity, eight data bits, and one stop bit (but it may be necessary to restart the DSP completely if theserial port does not work.) It then accepts characters received from the PC by the UART ( Universal Asynchronous Receiver/Transmitter ) and buffers them in memory until your code retrieves them. It also can accept ablock of bytes to transmit and send them to the UART in sequence.

Two macros are used to control the serial port: READSER and WRITSER . Both accept one parameter. READSER n reads up to n characters from the serial input buffer (the data coming from the PC) and places them in memory starting at *AR3 . ( AR3 is left pointing one past the last memory location written.) The actual number ofcharacters read is left in AR1 . If AR1 is zero, then no characters were available in the input buffer.

WRITSER n adds n characters starting at *AR3 to the serial output buffer; in other words, it queues them to besent to the PC. AR3 is left pointing one location after the last memory location read.

Note that READSER and WRITSER modify registers AR0 , AR1 , AR2 , AR3 , and BK , as well as the flag TC . Be sure you restore these registers after calling READSER and WRITSER if you need them later in your code.

Note also that the core file allows up to 126 characters to be stored in the input and output buffers. Neither the DSPhardware nor the core file protect against serial-buffer overflows, so you must be careful not to allow the input andoutput buffers to overflow. (The length of the buffers can be changed by editing ser_rxlen and ser_txlen values in core.asm .) The buffers are 127 characters long; however, the code cannotdistinguish between a completely-full and completely-empty buffer. Therefore, only 126 characters can be stored in thebuffers.

It is easy to check if the input or output buffers in memory are empty. The input buffer can be checked by comparing thevalues stored in the memory locations srx_head and srx_tail ; if both memory locations hold the same value, the input buffer is empty. Likewise, the outputbuffer can be checked by comparing the values stored in memory locations stx_head and stx_tail . The number of characters in the buffer can be computed bysubtracting the head pointer from the tail pointer; add the length of the buffer (normally 127) if the resulting distanceis negative.

The following example shows the minimal amount of code necessary to echo received data back through the serialport. It is available as ser_echo.asm .

1 .copy "core.asm" 2 3 .sect ".data" 4 hold .word 0 5 6 .sect ".text" 7 main 8 stm #hold,AR3 ; Read to hold location 9 10 READSER 1 ; Read one byte from serial port 11 12 cmpm AR1,#1 ; Did we get a character? 13 bc main,NTC ; if not, branch back to start 14 15 stm #hold,AR3 ; Write from hold location 16 WRITSER 1 ; ... one byte 17 18 b main

Questions & Answers

prostaglandin and fever
Maha Reply
Discuss the differences between taste and flavor, including how other sensory inputs contribute to our  perception of flavor.
John Reply
taste refers to your understanding of the flavor . while flavor one The other hand is refers to sort of just a blend things.
Faith
While taste primarily relies on our taste buds, flavor involves a complex interplay between taste and aroma
Kamara
which drugs can we use for ulcers
Ummi Reply
omeprazole
Kamara
what
Renee
what is this
Renee
is a drug
Kamara
of anti-ulcer
Kamara
Omeprazole Cimetidine / Tagament For the complicated once ulcer - kit
Patrick
what is the function of lymphatic system
Nency Reply
Not really sure
Eli
to drain extracellular fluid all over the body.
asegid
The lymphatic system plays several crucial roles in the human body, functioning as a key component of the immune system and contributing to the maintenance of fluid balance. Its main functions include: 1. Immune Response: The lymphatic system produces and transports lymphocytes, which are a type of
asegid
to transport fluids fats proteins and lymphocytes to the blood stream as lymph
Adama
what is anatomy
Oyindarmola Reply
Anatomy is the identification and description of the structures of living things
Kamara
what's the difference between anatomy and physiology
Oyerinde Reply
Anatomy is the study of the structure of the body, while physiology is the study of the function of the body. Anatomy looks at the body's organs and systems, while physiology looks at how those organs and systems work together to keep the body functioning.
AI-Robot
what is enzymes all about?
Mohammed Reply
Enzymes are proteins that help speed up chemical reactions in our bodies. Enzymes are essential for digestion, liver function and much more. Too much or too little of a certain enzyme can cause health problems
Kamara
yes
Prince
how does the stomach protect itself from the damaging effects of HCl
Wulku Reply
little girl okay how does the stomach protect itself from the damaging effect of HCL
Wulku
it is because of the enzyme that the stomach produce that help the stomach from the damaging effect of HCL
Kamara
function of digestive system
Ali Reply
function of digestive
Ali
the diagram of the lungs
Adaeze Reply
what is the normal body temperature
Diya Reply
37 degrees selcius
Xolo
37°c
Stephanie
please why 37 degree selcius normal temperature
Mark
36.5
Simon
37°c
Iyogho
the normal temperature is 37°c or 98.6 °Fahrenheit is important for maintaining the homeostasis in the body the body regular this temperature through the process called thermoregulation which involves brain skin muscle and other organ working together to maintain stable internal temperature
Stephanie
37A c
Wulku
what is anaemia
Diya Reply
anaemia is the decrease in RBC count hemoglobin count and PVC count
Eniola
what is the pH of the vagina
Diya Reply
how does Lysin attack pathogens
Diya
acid
Mary
I information on anatomy position and digestive system and there enzyme
Elisha Reply
anatomy of the female external genitalia
Muhammad Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Dsp laboratory with ti tms320c54x. OpenStax CNX. Jan 22, 2004 Download for free at http://cnx.org/content/col10078/1.2
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Dsp laboratory with ti tms320c54x' conversation and receive update notifications?

Ask