You are on page 1of 2

Discussion

Based on this experiment 4, we in group discuss about C language Programming using


PIC18F45K22 in MPLAB IDE. We learned how to write function to create Time Delay code
using Timers. Then, we understand Programming Timers of PIC18 and their associated
register. We are to examine the structure of C program for PIC 18. First, in exercise 1, we
created the new project by follow a few simple step as shown before (Lab 3). Next, we write
the program ->compile, we connect the trainer board, write the programme code and observe
the pattern of circuit in Proteus 8 and get the output.

Next step, we go through to change PSA and TOPS<2:0) bits of the TOCON or Timer0
module register which determine the prescalar assignment and prescalar ratio to 1:8 or 1:256.
We change the TOCON to 0b11000010 and Tops to 1:8 , 0b11000111 and Tops to 1.256
based on PIC18F45K22 datasheet. This have state on it and we just follow the instructions.
Save data and run the program and check the output that are connected to trainer board and
observe the LED will light up depends on timer.

Then, we put the TOCON register in original setting ob11000101. We change the code for
OSCON or Oscillator Control register change the in internal oscillator 4 MHZ to 16MHZ
refer to datasheet page 32. We change OSCON to Ox72 and get the output so the TOCON
stay in original setting, save the files and run the simulation check the output on the trainer
board. Next, same step to OSCON Ox52.

Lastly, we put the TOCON register and OSCON register in original setting, back to
normal that are state. Then, change TMROL register to = TMROL 10.Refer to code given,
and we just change the TMROL before this 100 to 10. So, save the files and run simulation
and reset on trainer board and observe the output of LED will light up.

CONCLUSION

In the end of this experiment, we conclude that in C language programming we learned


how to write function create Time Delay code Using Timers. Understanding Programming
Timers of PIC18 and their associated register, and examine the structure of C program for
PIC 18. We understand that software selectable operation as a timer or counter in both 8 bit or
18 bit modes. The TOCON register control all aspects of the modules operation ,including
the prescale selection. It all refer to PIC datasheet. We just change the TOCON and OSCON
based on question given. At the end, we can get the results or output of LED on trainer board
is light up based on Timer change.

You might also like