General Purpose Input/Output Labs
EXAMPLE 3-9:
INITIALIZE() CODE FOR LAB 3
//Set all PORTC bits HIGH (to a known state)
PORTC = 0b11111111;
//Configure PORTC's ANALOG/DIGITAL pins as all Digital
ANS4 = 0;//Associated with RC0
ANS5 = 0;//Associated with RC1
ANS6 = 0;//Associated with RC2
ANS7 = 0;//Associated with RC3
ANS8 = 0;//Associated with RC6
ANS9 = 0;//Associated with RC7
//Configure PORTC
//i.e. 1 = Input,
TRISC0 = 0;//Make
TRISC1 = 0;//Make
TRISC2 = 0;//Make
TRISC3 = 0;//Make
TRISC4 = 0;//Make
TRISC5 = 0;//Make
TRISC6 = 0;//Make
TRISC7 = 0;//Make
pins as all output
0 = Output
RC0 (pin 16) output
RC1 (pin 15) output
RC2 (pin 14) output
RC3 (pin 7) output
RC4 (pin 6) output
RC5 (pin 5) output
RC6 (pin 8) output
RC7 (pin 9) output
//Configure Timer0 as follows:
T0CS = 0; //Use the internal instruction clock
//FOSC/4 as the clock source
T0SE = 0;//Increment TMR0 on low-to-high
//FOSC/4 transition
PSA = 0;//Assign the prescaler to
//Timer0
//Configure Timer0 prescaler to increment
//TMR0 every 256 FOSC/4 clock transitions
PS0 = 1;
PS1 = 1;
PS2 = 1;
3. Finally, copy/paste the code in Example 3-10 into the Timing() over the code
from the previous lab
EXAMPLE 3-10:
TIMING() CODE FOR LAB 3
Delay_1S(); //Call the 1 second delay
4. The remaining code from the previous lab remains the same. Compile the proj-
ect. There should be no errors.
3.3.6.4
TESTING THE APPLICATION
Program the PIC16F690. The application should behave exactly as it did in the
previous lab. Using an oscilloscope to test individual PORTC pin level transitions would
be useful to analyze the accuracy of the delay.
The solution for this project is located in the
C:\PICDEM_Lab\GPIO_Labs\GPIO_Lab3\solution directory .
Note:
? 2009 Microchip Technology Inc.
More in-depth tutorials on the Timer0 peripheral are covered in “Timers:
Timer0 Tutorial (Part 1)” (5162a.pdf) and “Timers: Timer0 Tutorial (Part 2)”
(51702a.pdf) files included on the PICDEM? Lab Development Kit CD.
DS41369A-page 33
相关PDF资料
DM164120-1 BOARD DEMO PICKIT 2 LP COUNT
DM164120-3 BOARD DEMO PICKIT2 28-PIN
DM164120-5 BOARD DEMO PICKIT 2 64/80-PIN
DM164123 KIT MANAGEMENT SYSTEM PICDEM
DM180021 KIT STARTER MPLAB FOR PIC18F MCU
DM183022 BOARD DEMO PIC18FXX22 64/80TQFP
DM183032 BOARD EXPLORER PICDEM PIC18
DM240001 BOARD DEMO PIC24/DSPIC33/PIC32
相关代理商/技术参数
DM163035+TEFLCST3 制造商:Microchip Technology Inc 功能描述:KIT PICDEMLAB+FLOWCODE-HOME BUNDLE/ 制造商:Microchip Technology Inc 功能描述:PICDEM, FLOW CODE, LAB, DEV KIT
DM163045 功能描述:开发板和工具包 - PIC / DSPIC PICDEM Lab Dev Kit (with PICkit 3) RoHS:否 制造商:Microchip Technology 产品:Starter Kits 工具用于评估:chipKIT 核心:Uno32 接口类型: 工作电源电压:
DM1-63-C 功能描述:端子 Metric Fem Disc non-insulated RoHS:否 制造商:AVX 产品:Junction Box - Wire to Wire 系列:9826 线规:26-18 接线柱/接头大小: 绝缘: 颜色:Red 型式:Female 触点电镀:Tin over Nickel 触点材料:Beryllium Copper, Phosphor Bronze 端接类型:Crimp
DM1-63M-C 功能描述:端子 Metric Male Disc non-insulated, 0 RoHS:否 制造商:AVX 产品:Junction Box - Wire to Wire 系列:9826 线规:26-18 接线柱/接头大小: 绝缘: 颜色:Red 型式:Female 触点电镀:Tin over Nickel 触点材料:Beryllium Copper, Phosphor Bronze 端接类型:Crimp
DM164 制造商:SITI 制造商全称:SITI 功能描述:8x3-CHANNEL CONSTANT CURRENT LED DRIVER
DM1640 制造商:SANYO 制造商全称:Sanyo Semicon Device 功能描述:16 characters x 4 line Liquid Crystal Dot Matrix Display Module
DM1640-0AL1 制造商:未知厂家 制造商全称:未知厂家 功能描述:Optoelectronic
DM1640-0BL1 制造商:未知厂家 制造商全称:未知厂家 功能描述:Optoelectronic