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.

Can anyone explain this about PIC Code??

Status
Not open for further replies.

ajex

Member level 4
Joined
Nov 7, 2009
Messages
70
Helped
6
Reputation
12
Reaction score
6
Trophy points
1,288
Location
Sri lanka
Activity points
1,813
hello..

I have written 2 code using MPLAB C30 compiler and MikroC dsPIC compiler for dsPIC30F6014A..

two codes are like below..

In MPLAB C30>>

PORTDbits.RD1 = 1;
PORTDbits.RD1 = 0;
PORTDbits.RD2 = 1;


In MikroC >>

const char ONE = 1;
const char TWO = 2;

PORTD.ONE = 1;
PORTD.ONE = 0;
PORTD.TWO = 1;

I expected the same result form both codes.. But results as follows..

In MPLAB C30>> PORTD 1st bit(RD1) set as 1 (but i'm expecting 0) 8-O

In MikroC >> PORTD 1st bit(RD1) set as 0

Can anyone explain this???????


And after inserted a delay to MPLAB C30 code it gave the correct results as mikroC code (PORTD 1st bit(RD1) set as 0) ... :-D

like this>>

PORTDbits.RD1 = 1;
delay(10);
PORTDbits.RD1 = 0;
delay(10);
PORTDbits.RD2 = 1;

Is this happened due to PORTD register writing delay???????? can't believe it...!!!!!
 
Last edited:

Try writing to Latches instead of PORT
like this

LATDbits.LATD1=1;
I had read somewhere that for writing we should use Latches and for reading we should use PORT
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top