<< 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

I'm interested in biological psychology and cognitive psychology
Tanya Reply
what does preconceived mean
sammie Reply
physiological Psychology
Nwosu Reply
How can I develope my cognitive domain
Amanyire Reply
why is communication effective
Dakolo Reply
Communication is effective because it allows individuals to share ideas, thoughts, and information with others.
effective communication can lead to improved outcomes in various settings, including personal relationships, business environments, and educational settings. By communicating effectively, individuals can negotiate effectively, solve problems collaboratively, and work towards common goals.
it starts up serve and return practice/assessments.it helps find voice talking therapy also assessments through relaxed conversation.
miss
Every time someone flushes a toilet in the apartment building, the person begins to jumb back automatically after hearing the flush, before the water temperature changes. Identify the types of learning, if it is classical conditioning identify the NS, UCS, CS and CR. If it is operant conditioning, identify the type of consequence positive reinforcement, negative reinforcement or punishment
Wekolamo Reply
please i need answer
Wekolamo
because it helps many people around the world to understand how to interact with other people and understand them well, for example at work (job).
Manix Reply
Agreed 👍 There are many parts of our brains and behaviors, we really need to get to know. Blessings for everyone and happy Sunday!
ARC
A child is a member of community not society elucidate ?
JESSY Reply
Isn't practices worldwide, be it psychology, be it science. isn't much just a false belief of control over something the mind cannot truly comprehend?
Simon Reply
compare and contrast skinner's perspective on personality development on freud
namakula Reply
Skinner skipped the whole unconscious phenomenon and rather emphasized on classical conditioning
war
explain how nature and nurture affect the development and later the productivity of an individual.
Amesalu Reply
nature is an hereditary factor while nurture is an environmental factor which constitute an individual personality. so if an individual's parent has a deviant behavior and was also brought up in an deviant environment, observation of the behavior and the inborn trait we make the individual deviant.
Samuel
I am taking this course because I am hoping that I could somehow learn more about my chosen field of interest and due to the fact that being a PsyD really ignites my passion as an individual the more I hope to learn about developing and literally explore the complexity of my critical thinking skills
Zyryn Reply
good👍
Jonathan
and having a good philosophy of the world is like a sandwich and a peanut butter 👍
Jonathan
generally amnesi how long yrs memory loss
Kelu Reply
interpersonal relationships
Abdulfatai Reply
What would be the best educational aid(s) for gifted kids/savants?
Heidi Reply
treat them normal, if they want help then give them. that will make everyone happy
Saurabh
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