2 Pages

How to Determine the Length of a String

Course: CS 124, Winter 2012
School: BYU
Rating:
 
 
 
 
 

Word Count: 229

Document Preview

to How Determine the Length of a String... A C string can be created from a binary data type by using the sprintf() function. By including the standard C I/O library ("#include <stdio.h>" and defining a character array of sufficient size for the string, the pen coordinates can be converted from binary to ASCII. #include <stdio.h> char buffer[16]; ... sprintf(buffer,...

Register Now

Unformatted Document Excerpt

Coursehero >> Utah >> BYU >> CS 124

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
to How Determine the Length of a String... A C string can be created from a binary data type by using the sprintf() function. By including the standard C I/O library ("#include <stdio.h>" and defining a character array of sufficient size for the string, the pen coordinates can be converted from binary to ASCII. #include <stdio.h> char buffer[16]; ... sprintf(buffer, "%d", x); The length of a C string can be determined empirically by checking the size of the number. (ie, greater than 9999 = 5, greater than 999 = 4, etc.) Or, you can "#include <string.h>" and call the function: int strlen(const char *); The strlen() function computes the number of bytes in the string to which the parameter not points, including the terminating null byte. The strlen() function returns the length of the C string; no return value is reserved to indicate an error. The optional length specification parameter of the printf and sprintf functions can be used (when enabled) to create a string of a specific length by including the size between the "%" and the conversions specification. sprintf(buffer, "%10d", x); // convert x to a string of 10 characters NOTE: To enable the full functionality of the printf and sprintf functions, select your CCS project, follow the drop-down menus to Library Function Assumptions (Project>Properties->C/C++ Build), and select full Level of printf support required (-printf_support). i.e.
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

BYU - CS - 124
How to Draw a Continuous Line.A continuous line is drawn if neither the delta x nor delta y is greater than 1 pixel. Inthe following example, the x value always increments by 1 while the y value onlydecrements by 1 when needed to conform to the &quot;ideal&quot;
BYU - CS - 124
How to Draw Images and Text on theLCD.The New Haven NHD-C160100DiZ-FSW-FBW LCM (Liquid Crystal DisplayGraphic Module) is a 160 column x 100 row, 16-level dot, reflective, LiquidCrystal Display with a side white LED backlight. Display data and commands
BYU - CS - 124
How to Draw Various Shapes.Draw a circle on the LCD by calling:void lcd_circle(int x0, int y0, int r0, int pen);wherex0, y0 = coordinates of the center of the circler0 = radius of circlepen = pen value (0 = erase, 1 = single line)Example:lcd_circl
BYU - CS - 124
How To Generate A Random Number.Use the following routines found in random.asm to initialize, set, and getrandom numbers:FunctioninitRand16rand16setRandSeedgetRandSeedParametersIN: r12 = random seedOUT: r12 = random number (0-32767)IN: r12 = ra
BYU - CS - 124
How To Implement An Event Driven ProgrammingModel.In your introductory programming courses and our labs thus far, you mostlyused the basic program structures of sequential, conditional, and iterativecode associated with a procedural program. If you lo
BYU - CS - 124
How To Interface With eZ430XLibraries.eZ430X Librariesadc.h, adc.co int ADC_init(void);o int ADC_read(int channel);adxl345.h, adxl345.co int ADXL345_init(void);o unsigned char ADXL345_read(unsigned char regaddr, unsignedchar *buf, int count);o v
BYU - CS - 124
How To Link Programs.Part of systemic decomposition usually involves dividing a program intoseparate files. Smaller files are easier to maintain and support ObjectOriented Programming (OOP) by &quot;hiding&quot; or encapsulating data. The problemof coming up wi
BYU - CS - 124
How To Make Subroutines Callee-Save.Any register used by a subroutine MUST be saved and restored from thestack! The following routine illustrates this procedure:;-; SUBROUTINE: GENERATES NEXT RANDOM NUMBER;;OUT:r12 = 0-32767;random seed updated;
BYU - CS - 124
How To Setup MSP430 Ports.The most straightforward form of input/output of the MSP430 is through thedigital input/output ports. The following table summarizes the control registersfor ports P1, P2, P3, and P4 of the MSP430F2274:PxDIR Port Px Direction
BYU - CS - 124
How to Use C Struct's.Tidy programs are a blessing to programmers. Tidy data are just as important. Asprograms become increasingly complex, their data also grow in complexity andsingle, independent variables or arrays are no longer enough. What one the
BYU - CS - 124
How to Use malloc.Let's say that you would like to allocate a certain amount of memory during theexecution of your program. You can call the malloc function at any time, and it willrequest a block of memory from the heap. The system will reserve a bloc
BYU - CS - 124
How to Use the ADXL345 Accelerometer.The ADXL345 is a small, thin, low power, 3-axis accelerometer with high resolution(13-bit) measurement at up to 16 g. Digital output data is formatted as 16-bit twoscomplement and is accessible through the I2C digit
BYU - CS - 124
How to Use the MSP430 Analog to Digital Converters.The MSP430F2274 process has a high-performance 10-bit analog-to-digital converter.(See slau144e - MSP430x2xx Family User's Guide.pdf.)ADC10 features include:Greater than 200 ksps maximum conversion ra
BYU - CS - 124
How To Use Timer_A for PWM of Tones.Pulse-width modulation, or PWM, provides an adequate substitute for aDigital-to-Analog (DAC) in many applications. By varying the width of pulsessent to a device (such as a speaker or LED), a purely digital signal ca
BYU - CS - 124
How To Use Timer_A for PWM of Tones.Pulse-width modulation, or PWM, provides an adequate substitute for aDigital-to-Analog (DAC) in many applications. By varying the width of pulsessent to a device (such as a speaker or LED), a purely digital signal ca
BYU - CS - 124
How To Write C ISRs.A C Interrupt Service Routine (ISR) is created using a pre-processor#pragma vector=directive. (See msp430x22x4.h for specific vector names.)Before a device will interrupt, it has to be enabled plus the GIE status registerbit must
BYU - CS - 124
CS/ECEn 124, W2012Homework #1Abstraction (Ch 2)NameQuestions:SectionScoreAnswers:/ 411. (3 points) Can a higher level programminglanguage instruct a computer to compute morethan a lower level programming language?Explain.2. (3 points) Name th
BYU - CS - 124
CS/ECEn 124, W2012Homework #2Digital Logic (Ch 3)NameQuestions:Answers:1. (4 points) How many select lines and howmany output lines do the following multiplexershave?a.b.c.d.Score/ 38# of input lines# of select lines# of output lines321
BYU - CS - 124
CS/ECEn 124, W2012Homework #3Digital Logic (Ch 3)NameQuestions:SectionScoreAnswers:/461. (10 points) Identify the type of logic(combinational or sequential) for each of thefollowing:a. ALUb. D-latchc. Decoderd. Drivere. Flip-Flopf. Invert
BYU - CS - 124
CS/ECEn 124, W2012Homework #4Von Neumann (Ch 4)MSP430 ISA (Ch 5)NameQuestions:Answers:SectionScore/ 471. (11 points) For each statement below, indicateif a CISC or RISC architecture is best described:a.b.c.d.e.f.g.h.i.j.k.Cheaper pr
BYU - CS - 124
CS/ECEn 124, W2012Homework #7Stacks (Ch 8)Interrupts (9)NameQuestions:SectionScoreAnswers:/ 361. (3 points) Define subroutine cohesion. Whatproperties of cohesion should be found in yoursubroutines?2. (3 points) Define subroutine coupling. Wh
BYU - CS - 124
I2C Bus Events: The START and STOP conditionsPrior to any transaction on the bus, a START condition needs to be issued on the bus. The startcondition acts as a signal to all connected IC's that something is about to be transmitted on the bus.As a resul
BYU - CS - 124
Application ReportSLAA368 September 2007Using the USI I2C Code LibraryPriya Thanigai . MSP430 ApplicationsABSTRACTThis document serves as an overview of the master and slave code libraries for I2Ccommunication using the USI module as found on the MS
BYU - CS - 124
Application ReportSLAA382 December 2007Using the USCI I2C MasterUli Kretzschmar . MSP430 SystemsChristian Hernitscheck . MSP430 Application EuropeABSTRACTThis document is an overview of the use of the I2C master function set for MSP430devices with
BYU - CS - 124
Application ReportSLAA383 December 2007Using the USCI I2C SlaveUli Kretzschmar . MSP430 SystemsChristian Hernitscheck . MSP430 Application EuropeABSTRACTThis document is an overview of the use of the I2C slave function set for MSP430devices with th
BYU - CS - 124
Using the I2C BusJudging from my emails, it is quite clear that the I2C bus can be very confusing for the newcomer. I have lots ofexamples on using the I2C bus on the website, but many of these are using high level controllers and do notshow the detail
BYU - CS - 124
An introduction to the TI MSP430 low-powermicrocontrollersOverviewThe MSP430 is a very clean 16-bit byte-addressed processor with a 64K unified address space, and memorymapped peripherals. The current family includes a variety of on-chip peripherals, a
BYU - CS - 124
010203040506070809010011012013014015001020304050607080901001101201301401509080706050403020100
BYU - CS - 124
Example Initialization Program/*//*/void write_command(unsigned char datum)cfw_A0=0; /*Instruction register*/E=1; /*Read inactive*/bus=datum; /*put data on port 1*/CSB=0; /*Chip select active*/RW=0; /*Write active*/RW=1; /*Write inactive; latch
BYU - CS - 124
Page 1Page 223222120191817161514131211109876543210Page 0FRAM(162)FRAM(163)FRAM(164)FRAM(2)FRAM(3)FRAM(4)FRAM(159)01234159FRAM(319)FRAM(161)FRAM(1)FRAM(479)FRAM(324)FRAM(323)FRAM(322)FRAM(321)FRAM(320)765
BYU - CS - 124
Users GuideNHD-C160100DiZ-FSW-FBWLCMNHD160100DiZFSWFBW-(Liquid Crystal Display Graphic Module)COG- RoHS CompliantNewhaven Display 160 x 100 Dots Version Line Transflective Side White LED B/L FSTN (+) 6:00 View Wide Temperature (-20 ~ +70c)For produ
BYU - CS - 124
STSitronixINTRODUCTIONST752816 Gray Scale Dot Matrix LCD Controller/DriverThe ST7528 is a driver &amp; controller LSI for 16-level gray scale graphic dot-matrix liquid crystal display systems. It contains 2 Mode (160X100,132X128) for Segment and Common d
BYU - CS - 124
Linux gcc C CompilerFor those wanting to use Linux on their home computers, look atthe KNOPPIX website (http:/www.knoppix.net/) for a free Linux systembootable from CD ROM.For those who do not own a computer or would just rather do their work usingBY
BYU - CS - 124
Master / Slave D Type Flip-Flop TutorialA couple of definitions :RIPPLE THROUGH. An input changes level during the clock period, and the change appears at the output.PROPAGATION DELAY. The time between applying a signal to an input, and the resulting ch
BYU - CS - 124
Morse CodeFrom Wikipedia, the free encyclopediaMorse code is a type of character encoding that transmitstelegraphic information using rhythm. Morse code uses astandardized sequence of short and long elements to representthe letters, numerals, punctua
BYU - CS - 124
MSP430 C Intrinsic OperatorsThe compiler recognizes a number of intrinsic operators. Intrinsics are usedlike functions and produce assembly language statements that wouldotherwise be inexpressible in C. You can use C variables with these intrinsics,ju
BYU - CS - 124
Single-Operand Instructions (II)RRC.WR4 ( dst dst)100xSWPBR4 ( dst dst)108xRRA.WR4 ( dst dst)110xSXTR4 ( dst dst)118xPUSH.W R4 (src @-SP)120xCALLR4 (PC @-SP, dst PC)128xRETI (@SP+ SR, @SP+ PC)130x?138x00000000Op-Code Field00
BYU - CS - 124
How to Assemble/Disassemble (aka Hack) MSP430 CodeTo decode an instruction:1. Begin with a PC pointing to the first word in program memory.2. Retrieve instruction word and increment PC by 2.3. Find and list the corresponding instruction mnemonic using
BYU - CS - 124
MSP430 instruction set1514131211100001000001000000001000000010001000100010001001000010010001001001condition10-bit signed offset00100010-bit signed offsetJNE/JNZ Jump if not eq
BYU - CS - 124
1.References Allan V. Oppeiheim, Alan S. Willsky, Hamid Nawab, Signals &amp;Systems, 2nd edition, Prentice Hall, 1997. AndreasDannenberg,Designingsingle-chipportableapplications for full-bridge sensor data acquisition using alowpower MCU with integra
BYU - CS - 124
Negative Numbers and BinarySubtractionWe have seen how simple logic gates can perform the process of binaryaddition. It is only logical to assume that a similar circuit could perform binarysubtraction.If we look at the possibilites involved in subtra
BYU - CS - 124
Secrets of printf Professor Don ColtonBrigham Young University Hawaiiprintf is the C language function to do formatted printing. The same function is also available inPERL. This paper explains how printf works, andhow to design the proper formatting
BYU - CS - 124
Program DevelopmentIn short, in daily life, almost everything we do involves constant feedback onwhether we're doing it right. Why would programming be any different? Veryfew of us, especially when just starting out, will create a program that JustWor
BYU - CS - 124
RF Networking With the MSP430 &amp; eZ430-RF2500 Session 1 Miguel Morales, MSP430 Applications6/5/2008 1Agenda SimpliciTI Overview Lab Hardware Description Session 1 Lab Overview Lab 1.1 Wired Sensor Monitor [UART] Lab 1.2 SimpliciTI Semaphores Lab 1.3 Inte
BYU - CS - 124
Application ReportSLAA378A December 2007 Revised December 2007Wireless Sensor Monitor Using the eZ430-RF2500Miguel Morales . MSP430 Applications ABSTRACT This application report documents the wireless temperature-sensor network demonstration applicatio
BYU - CS - 124
RF Basics, RF for Non-RF EngineersDag Grini Program Manager, Low Power Wireless Texas2006 Texas Instruments Inc, Slide 1 Instruments Agenda Basics Basic Building Blocks of an RF System RF Parameters and RF Measurement Equipment Support / getting starte
BYU - CS - 124
CC2500CC2500 Low-Cost Low-Power 2.4 GHz RF TransceiverApplications 2400-2483.5 MHz ISM/SRD band systems Consumer electronics Wireless game controllers Wireless audio Wireless keyboard and mouse RF enabled remote controlsProduct DescriptionThe CC2500
BYU - CS - 124
03-CLements-Chap03.qxd17/1/0611:10 PMPage 101Sequential LogicCHAPTER MAP2 Logic elements and Boolean algebraWe begin our introduction to the computer with the basic building block from which we construct all computers, the gate. A combinational dig
BYU - CS - 124
The purpose of this article is to give an overview of how servos operate and to describe their interfaces. Though we havetaken steps to assure the quality of information here, Brookshire Software, LLC makes no guarantees about theinformation presented h
BYU - CS - 124
HOBBYHOBBYSERVOFUNDAMENTALSBY: DARREN SAWICZI N T R O D U CT I O Nobby servos are a popular andinexpensive method of motioncontrol. They provide an off-the-shelfsolution for most of the R/C androbotic hobbyist's needs. Hobbyservos eliminate the
BYU - CS - 124
R/C SERVO TESTERThis pocket sized servo signal emulator makes it a breeze to test and setupyour servos. It features digital accuracy and is easy to build and use.IntroductionI recently found myself having to test a large number of R/C servo controlled
BYU - CS - 124
Whats a Servo?A Servo is a small device that has an output shaft. This shaft can be positioned to specific angular positions bysending the servo a coded signal. As long as the coded signal exists on the input line, the servo will maintain theangular po
BYU - CS - 124
B Y BA R RY L D O R R D O R R E N G I N E E R I N GA simple software lowpass filter suits embeddedsystem applicationsBUILDING A DIGITAL EQUIVALENT OF AN ANALOG LOWPASS RC FILTER REQUIRES JUST A COUPLE OF LINES OF FIXED-POINT C CODE.Hardware-design eng
BYU - CS - 124
Application ReportSLAA334A September 2006 Revised April 2008MSP430 Flash Memory CharacteristicsPeter Forstner . MSP430 Applications ABSTRACT Flash memory is a widely used, reliable, and flexible nonvolatile memory to store software code and data in a m
BYU - CS - 124
MSP430F2xx Family Enhancements and FeaturesMike Mitchell MSP430 Applications Engineer Texas2006 Texas Instruments Inc, Slide 1 Instruments Agenda Enhancements Application Examples Devices &amp; Summary 2006 Texas Instruments Inc, Slide 2MSP430 ProductsD
BYU - CS - 124
MSP430x22x2, MSP430x22x4 MIXED SIGNAL MICROCONTROLLERSLAS504B - JULY 2006 - REVISED JULY 2007D Low Supply Voltage Range 1.8 V to 3.6 V D Ultralow-Power ConsumptionD Two Configurable Operational Amplifiers D DD D DD D DD- Active Mode: 270 A at 1 MHz
BYU - CS - 124
MSP430x20x1, MSP430x20x2, MSP430x20x3 MIXED SIGNAL MICROCONTROLLERSLAS491D - AUGUST 2005 - REVISED SEPTEMBER 2007D Low Supply Voltage Range 1.8 V to 3.6 V D Ultralow Power ConsumptionD D D DD D D D D- Active Mode: 220 A at 1 MHz, 2.2 V - Standby Mode
BYU - CS - 124
Chapter 3RISC 16 Bit CPUThis chapter describes the MSP430 CPU, addressing modes, and instruction set.Topic3.1 3.2 3.3 3.4PageCPU Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2 CPU Registers
BYU - CS - 124
MSP430 Assembly Language Tools v 3.0User's GuideLiterature Number: SLAU131B March 20082SLAU131B March 2008 Submit Documentation FeedbackContentsPreface. 13 11.1 1.2. 15 Software Development Tools Overview . 16 Tools Descriptions. 17Introduction t
BYU - CS - 124
MSP430 Optimizing C/C+ Compiler v 3.1User's GuideLiterature Number: SLAU132C November 20082SLAU132C November 2008 Submit Documentation FeedbackContentsPreface . 9 11.1 1.2. 13 Software Development Tools Overview . 14 C/C+ Compiler Overview . 16 1.