Conversion between pic18f458 and pic16f690 with xc8 function tables

Thread Starter

johnnyinwa

Joined Jun 24, 2013
61
Heh Guys,
I am using the microchip XC8 C compiler (free version) with the MPLABX IDE on windows VISTA.

I had three questions for converting pic18f458 code to pic16f690 code:
Question #1 -- TRISD=0 and TRISbits.TRISD=0 -- What is the correct syntax for the pic16f690?
Question #2 -- LATD=0b10101010 and LATDbits.LATD0=1 -- What is the correct syntax for the pic16f690?
Question #3 -- if (PORTDbits.RD0==1) Return; What is the correct syntax for the pic16f690?
Question number one sets a port or a bit to output or input.
Question number two writes to a port or a bit.
Question number three reads the status of a pin on a port.
I have attached a three page table of all the XC8 library functions for your use. Some of the explanations are inexact but they fit on the table. Thanks for your help. ;
 

Attachments

ErnieM

Joined Apr 24, 2011
8,377
Givens: PIC16F690, XC8 compiler

Question #1: set a port or a bit to output or input.
-- TRISD=0 and TRISbits.TRISD=0 -- What is the correct syntax for the pic16f690?

That is two different questions with two different answers. The former is correct for the whole port, the latter incorrect for the bit.

For a bit you need to specify WHICH bit, say TRISbits.TRISD0 = 0;

However, the PIC16F690 does not have a port D so you need to stick to one of the three ports it does have.


Question #2: write to a port or a bit.
-- LATD=0b10101010 and LATDbits.LATD0=1 -- What is the correct syntax for the pic16f690?

Neither. The latch is not the port, and the PIC16 series does not have the latch, it just has a port.

Now in the PIC18 series the latch and port instructions do indeed write to the same register, but they read different things; latch reads the register directly, while port reads the pin state associated with the latch.


Question number three reads the status of a pin on a port.
if (PORTDbits.RD0==1) Return; What is the correct syntax for the pic16f690?

That would be correct IF this device had a Port D.
 
Top