bai tap chuong 3

2 140 0
bai tap chuong 3

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

Thông tin tài liệu

BÀI TẬP CHƯƠNG List the syntax features that a minimal C program must contain if compiled for the PIC16F877A MCU List the steps required to create and test a C program for a PIC MCU prior to downloading to hardware Write a C statement that outputs the 8-bit value 6410 to Port C Write an alternative 1-bit output statement that has the same effect, assuming all the port bits are initially Describe briefly the difference between a WHILE loop, a DO WHILE loop, and a FOR loop Describe the effect of the following statements on active high LEDs connected to Port D, assuming an active low switch circuit is connected to pin RC7: output_D(255); delay_ms(1000); while(!input(PIN_C7)) { output_D(15); } output_D(0); Calculate the highest positive number that can be represented by the following variable types: (a) 8-bit unsigned integer, (b) 16-bit signed integer, (c) 32-bit floating point number Estimate the degree of precision provided by the following numerical types as a percentage, to two significant figures: (a) 8-bit integer, (b) 32-bit FP number Work out the value of the FP number represented by the binary code 1000 0010 0011 0000 0000 0000 0000 0000 Write a C statement to convert numbers to to their ASCII hex code, using variables ‘n’ for the number and ‘a’ for the ASCII code and send it to serial LCD 10 State the result of each of these operations in decimal and 4-bit binary, if n=5 and m=7 : (a) n++ (b) ~m (c) n&m (d) n|m (e) n^m 11 State the effect of the jump commands continue, break, and goto label when used within a program loop 12 A menu is required with a choice of three options to be selected by a numerical variable x=1, 2, Each option is implemented in a separate function, funx() Write a C code section to show how switch can be used to implement the menu 13 Explain why the use of local variables is preferable in C programs designed for microcontrollers with limited RAM 14 Explain how the use of functions leads to well-structured C programs and the benefits of this design approach 15 State the meaning of the source code items that are underlined: int out(int16 t) { int16 n; while (input(PIN_D0)) { outbyte++ ; for(n=1;n

Ngày đăng: 06/11/2017, 20:54

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

  • Đang cập nhật ...

Tài liệu liên quan