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.

[SOLVED] Problem in Coding using MPLAB

Status
Not open for further replies.

shahbaz.ele

Advanced Member level 1
Joined
Aug 12, 2008
Messages
454
Helped
72
Reputation
146
Reaction score
73
Trophy points
1,308
Location
Islamabad, Pakistan
Activity points
3,669
// Control signal pin direction
#define RW_TRIS TRISCbits.TRISC13
#define RS_TRIS TRISCbits.TRISC14
#define E_TRIS TRISCbits.TRISC15

// Data signals and pin direction
#define DATA LATF,LATA // Port for LCD data
#define DATAPORT PORTF,PORTA
#define TRISDATA TRISF,TRISA // I/O setup for data Port

Here is my code i want to define DATA as combined ports F and A (0 to 6 portF and 1 bit of porta) of dsPIC30F3014
 

hai shahbaz,

i think you can define as follows

#define DATA (portF shift bits to get 0 to 6)|(portA shift bits)
 

I don't think this will work. LAT and PORT registers are memory mapped same as all the rest of SFRs as data memory addresses 0x0000 to 0x07ff. LATA is at 0x02C4 and LATF is at 0x02F2. I don't think there is a way to do really fast access to those two (of course you can write data to some variable and then split them into separate latches one by one, but that's the only option i guess)
 

From that i understand that you're using 16-bit mcu (you have more than 8 bits per port). If that's the case you can write whole byte to bits 0-7 like that:

LATB&=0xff00;
LATB|=(0x0000|DATA);

this way you preserve whatever was on higher bits and overwrite anything that was on lower bits with data.
to manipulate RS and EN you can simply use
_LATB9=0;
_LATB8=1; etc. (at least in C30 you can do that, because definitions for single port bits are in header file for particular micro)
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top