DSP lab4 report Bach Khoa

16 71 1
DSP lab4 report Bach Khoa

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

File transceivingUsing TMS320C5515 eZDSPTM USB StickAssoc. Prof. Dr. Thuong Le TienThis report introduces how to read and write a file to the computer’s drive using the TMS320C5515 eZDSPTM USB Stick Development Tool. The goal of this lab is to read a text file on the computer’s drive and display them to the compiler’s console as well as on the LCD of the kit.In particular, this lab does the following:1. Create a text file named “in.txt” on the computer with the following content: “Advanced Program in Engineering Education_University of Technology”2. Read the file specified by its path then display its content on the LCD of the board and the CCS console.3. Write the text to another file named “out.txt”

Vietnam National University Ho Chi Minh City University of Technology Digital Signal Processing LAB REPORT File transceiving Using TMS320C5515 eZDSPTM USB Stick Instructor: Assoc Prof Dr Thuong Le -Tien Teaching Asisstants: Chi Hieu, Quoc Huy Group 7: Dat Nguyen-Si ID: ILI11006 In-class ID: Trung Le ID: 41103857 In-class ID: March, 27th 2014 March, 27th 2014 Adventure Works Marketing Plan Lab report Table of Contents [Type text] Page March, 27th 2014 Adventure Works Marketing Plan Lab report Abstract This report introduces how to read and write a file to the computer’s drive using the TMS320C5515 eZDSPTM USB Stick Development Tool The goal of this lab is to read a text file on the computer’s drive and display them to the compiler’s console as well as on the LCD of the kit In particular, this lab does the following: Create a text file named “in.txt” on the computer with the following content: “Advanced Program in Engineering Education_University of Technology” Read the file specified by its path then display its content on the LCD of the board and the CCS console Write the text to another file named “out.txt” [Type text] Page March, 27th 2014 Adventure Works Marketing Plan Lab report Introduction File transceiving plays an important role in various DSP applications It helps set up communication between data on the computer and peripherals on the kit Such communication expands the power of peripherals as they use the computer’s drive as an external source of data The LCD module in the TMS320C5515 eZDSPTM USB Stick Development Tool is a 96×16 monochrome OLED display screen LCD can be a very useful part in any microcontroller based project It helps to monitor variables and program status with simple texts or numbers TMS320C5515 eZdsp™ USB Stick Development Tool’s LCD module [Type text] Page March, 27th 2014 Adventure Works Marketing Plan Lab report Overview of file functions in stdio.h library [1] fopen() Declaration: FILE *fopen(const char *filename, const char *mode); Opens the filename pointed to by filename The mode argument may be one of the following constant strings: r read text mode w write text mode (truncates file to zero length or creates new file) a append text mode for writing (opens or creates file and sets file pointer to the end-of-file) rb read binary mode wb write binary mode (truncates file to zero length or creates new file) ab append binary mode for writing (opens or creates file and sets file pointer to the end-of-file) r+ read and write text mode w+ read and write text mode (truncates file to zero length or creates new file) a+ read and write text mode (opens or creates file and sets file pointer to the end-of-file) r+b or rb+ read and write binary mode w+b or wb+ read and write binary mode (truncates file to zero length or creates new file) a+b or ab+ read and write binary mode (opens or creates file and sets file pointer to the end-offile) If the file does not exist and it is opened with read mode (r), then the open fails If the file is opened with append mode (a), then all write operations occur at the end of the file regardless of the current file position If the file is opened in the update mode (+), then output cannot be directly followed by input and input cannot be directly followed by output without an intervening fseek, fsetpos, rewind, or fflush On success a pointer to the file stream is returned On failure a null pointer is returned [Type text] Page March, 27th 2014 Adventure Works Marketing Plan Lab report fseek() Declaration: int fseek(FILE *stream, long int offset, int whence); Sets the file position of the stream to the given offset The argument offset signifies the number of bytes to seek from the given whence position The argument whence can be: SEEK_SET Seeks from the beginning of the file SEEK_CUR Seeks from the current position SEEK_END Seeks from the end of the file On a text stream, whence should be SEEK_SET and offset should be either zero or a value returned from ftell The end-of-file indicator is reset The error indicator is NOT reset On success zero is returned On error a nonzero value is returned fread() Declaration: size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream); Reads data from the given stream into the array pointed to by ptr It reads nmemb number of elements of size size The total number of bytes read is (size*nmemb) On success the number of elements read is returned On error or end-of-file the total number of elements successfully read (which may be zero) is returned fwrite() Declaration: size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream); Writes data from the array pointed to by ptr to the given stream It writes nmemb number of elements of size size The total number of bytes written is (size*nmemb) On success the number of elements writen is returned On error the total number of elements successfully writen (which may be zero) is returned [Type text] Page March, 27th 2014 Adventure Works Marketing Plan Lab report fgetc() Declaration: int fgetc(FILE *stream); Gets the next character (an unsigned char) from the specified stream and advances the position indicator for the stream On success the character is returned If the end-of-file is encountered, then EOF is returned and the end-of-file indicator is set If an error occurs then the error indicator for the stream is set and EOF is returned feof() Declaration: int feof(FILE *stream); Tests the end-of-file indicator for the given stream If the stream is at the end-of-file, then it returns a nonzero value If it is not at the end of the file, then it returns zero fclose() Declaration: int fclose(FILE *stream); Closes the stream All buffers are flushed If successful, it returns zero On error it returns EOF [Type text] Page March, 27th 2014 Adventure Works Marketing Plan Lab report 9 Display a running text on the OLED column 2nd column 6th column 4th column 3rd column column column 10th 9th 7th 5th column 8th column 2nd column 6th column 4th column 3rd column 9th column 7th column 5th column 8th column The idea is simple Using human concept of scrolling as a displacement in time, we consecutively print adjacent segments of the string of interest Specifically, we set up an array of pixel columns of the string, then continuously print each time a segment of 96 pixel columns, i.e print column 0th to 9th, set the pointer to the left edge of the LCD, print column 1st to 10th, set the pointer to the left edge of the LCD, print column 2nd to 11th, etc Let’s consider the following example: First print (pixel column 0th – 9th)Second print (1st – 10th) Third print (2nd – 11th) 0 2nd column 6th column 3rd column 4th column 10th column 9th column 7th column 5th column 8th column 0th column (0th element of the array) The OLED driver SSD1306 [2] of the board indeed supports horizontal and vertical scrolling However, the text is limited to 128 pixels wide thus it cannot display longer texts which exceed that width To adapt to this feature and expand its function for longer text, we have developed our own horizontal scrolling algorithm which supports horizontal scrolling text of any size [Type text] Page 11th column 1st column 1st column This way, we are not limited to 128 columns as it only depends on the size of the array we set up (which can extend to infinite) The result animation is very smooth as the time interval between each print is very small, which makes our eyes perceive the animation as a smooth scrolling March, 27th 2014 Adventure Works Marketing Plan Lab report Source codes In this source code, for convenience, we print each letter from left to right Compare to the sample code, there are difference: The printLetter subroutine is modified so that it prints from left to right Segment re-map is set from to 95: OSD9616_send(0x00,0xa0); Scrolling settings are neglected Note: actually, the modification of printLetter is not necessary Instead, we can reverse all the hex codes we have made However, this step requires much more efforts to Also, we keep the old hex codes to easily compare the work with our friends The the oled_test.c is modified as follows: #include"usbstk5515.h" #include"usbstk5515_i2c.h" #include"usbstk5515_gpio.h" #include"lcd.h" #include #include #include "usbstk5515.h" #define OSD9616_I2C_ADDR 0x3C // OSD9616 I2C address // // ///* * // * * // * Int16 OSD9616_send( Uint16 comdat, Uint16 data ) * // * * // * Sends bytes of data to the OSD9616 * // * * // * */ Int16 OSD9616_send( Uint16 comdat, Uint16 data ) { Uint8 cmd[2]; cmd[0] = comdat & 0x00FF; // Specifies whether data is Command or Data cmd[1] = data; // Command / Data } return USBSTK5515_I2C_write( OSD9616_I2C_ADDR, cmd, ); /* * * * * Int16 OSD9616_multiSend( Uint16 comdat, Uint16 data ) * * * Sends multiple bytes of data to the OSD9616 * * [Type text] Page * * March, 27th 2014 Adventure Works Marketing Plan 10 Lab report * */ Int16 OSD9616_multiSend( Uint8* data, Uint16 len ) { Uint16 x; Uint8 cmd[10]; for(x=0;x

Ngày đăng: 15/10/2020, 16:19

Mục lục

  • Display a running text on the OLED

Tài liệu cùng người dùng

Tài liệu liên quan