Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC18F45K22 basic port state

Status
Not open for further replies.

sairfan1

Full Member level 1
Joined
Jun 12, 2010
Messages
97
Helped
4
Reputation
8
Reaction score
7
Trophy points
1,288
Location
Regina, Canada
Activity points
2,371
Hi, im working with EasyPIc7 at 3.3v 18F45K22 MCU and MikroC compiler.
unable to run this simple program, i checked with volt meter, when i press button RD6 there is logic 1 at RD6 of MCU. plz help

Code:
void main() {

 ANSELA = 0;
 ANSELB = 0;
 ANSELC = 0;
 
 TRISB = 0;
 TRISD = 0xFF;

 
 PORTB = 0xFF;
 //PORTD = 0x00;
 Delay_ms(1500);

 while(1){
  // if (LATD7_bit == 1) // also checked
  if (PORTD.RD6 == 1){
   PORTB = ~PORTB;
   Delay_ms(250);
  }
 }

}
 
Last edited:

18F45K22 is 5V device and 18LF45K22 is 3.3V device.
 

18F45K22 is 5V device and 18LF45K22 is 3.3V device.
According to the datasheet that I use, either variant can be used at 3.3 Volts:

Untitled.jpg
 

I have been using PIC 16F devices, new to 18F device, want to know what is concept of LAT ?
 

Use PORTx to read from pin's
LATx to write to pin's
TRISx to change the direction ( in and out )

If you want to read the value that was written last time, you can read the same by LATx with out any loading effect but PORTx value may be changed base on load connected to the PORTx pin's ( Capacitor load )

see this link PIC mid rage ( 16F )read modify write behavior of PORTx
https://www.mikroe.com/download/eng/documents/compilers/mikroc/pro/pic/help/rmw.htm
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top