CCS does not monitor this forum on a regular basis. Please do not post bug Reports on this forum. Send them to support ccsinfo. View previous topic :: View next topic.
|Published (Last):||19 February 2014|
|PDF File Size:||11.81 Mb|
|ePub File Size:||5.2 Mb|
|Price:||Free* [*Free Regsitration Required]|
To the right is a pin diagram of the PIC16F You will notice that some pins have more than one name. That is because pins can serve more than one purpose and it is up to the designer to decide how each pin is configured. Each bit in the register controls one pin as outlined in the register tables shown below. A '0' sets the pin to digital mode and a '1' sets the pin to analog mode.
AN0 will also be in analog mode RA0 disabled. Reading a pin that is set to analog mode will return a '0'. These are what the datasheet refer to as "unimplemented bits".
I've shown my code writing 0s to those locations. We can also access individual bits of a register. When you include xc. In our case, it includes pic16f This file contains all the information for the registers in our device. It also contains unions for each register with each bit or bit range named.
Therefore, you can set an individual analog port as follows:. The next set of registers to look at are the data direction registers. The name TRIS is a shortening of tri-state which refers to the possible states of a pin: logic 1 output, logic 0 output, high-impedance input.
If the bit is set to 0, that pin is an output. If a bit is set to 1, that pin is an input. This is easy to remember because a 0 looks like an O for Output and a 1 looks like an I for Input. Reading bit 3 will always return a 1, as RA3 is input only. This is necessary because it shares a pin with RC0. Once again, we can set or clear individual bits of the TRIS registers. The union in pic16f If you do not set these registers in your code, all the analog pins will be enabled.
Therefore, no digital pins that share an analog pin will function correctly. This is how you read a digital input. You can also read a digital output to check its current status. Writing to a pin that is currently an input will have no effect on the pin because the output latch will be disabled.
We will begin by disabling all analog inputs because we aren't using any. After that we will individually set pin RC0 to be an output. Finally, we will enter an endless loop and make the LED blink. The code to accomplish this is shown below. Replace the contents of your main. You can also directly download this code with comments here: main. Some devices have more than one configuration register. We will cover the configuration settings later. The compiler then uses that value to calculate how many cycles are required to give the requested delay.
Note that the delay functions completely halt execution for their duration. If we want to do other things while we are waiting for a certain amount of time to expire, we will need to use timers. Those will be covered later. It is good practice to use define statements to provide logical names to pins. In the example above, we could include the following definition:. Creating definitions for your pin names will go a long way towards making your code easier to understand.
This will help you reduce errors and minimize the time you spend debugging. In the next section we will learn about how interrupts are implemented. This will be useful for us as we learn how to use some of the peripheral features of the microcontroller such as timers. Once again, some bits are unimplemented because those pins do not exist on this device.
Adding the LED.
To the right is a pin diagram of the PIC16F You will notice that some pins have more than one name. That is because pins can serve more than one purpose and it is up to the designer to decide how each pin is configured. Each bit in the register controls one pin as outlined in the register tables shown below. A '0' sets the pin to digital mode and a '1' sets the pin to analog mode. AN0 will also be in analog mode RA0 disabled. Reading a pin that is set to analog mode will return a '0'.
16F690 PIC16F690. Datasheet pdf. Equivalent
Data Sheet. CMOS Microcontrollers with. Note the following details of the code protection feature on Microchip devices:. All of these methods, to our. Most likely, the person doing so is engaged in theft of intellectual property.
What "Define Clock_Frequency" to use for 16F690 with Internal OSC
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together. If nothing happens, download GitHub Desktop and try again. Go back. If nothing happens, download Xcode and try again. If nothing happens, download the GitHub extension for Visual Studio and try again. Here are some examples:. We'll use sdcc to compile code and pk2cmd to load it into flash program memory.
16F690 Datasheet PDF