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.

dsPIC30F6014A microcontroller port driver(read/write I/Opins of the port)

Status
Not open for further replies.

swapna u

Member level 1
Joined
May 10, 2012
Messages
41
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,657
Hi all,

I am using dsPIC30F6014A controller and I am trying to write a driver program to read/write the port pins. I am using C30 compiler. Since this controller has A,B,C,D,F,G ports I am writing a value to each port and trying to read the value written using functions for read/write operation. But I am facing some problems as mentioned below:
1. I am not able to read or write to PORTF and PORTG.
2. And also the value what I read/write is not getting reflected in the port registers(PORTA,PORTB...PORTG).
3. I am also not able to write a value more than "4000" to each of the ports though this is a 16 bit controller capable of reading/writing values upto 65535.

Please look into the issue and let me know. Please share the code to read/write to ports of dspic30f controller if you have it. Waiting for your earliest response.

Thankyou
Swapna
 

not all the bits exist in every port, see FIGURE 1-2: dsPIC30F6013A/6014A BLOCK DIAGRAM and TABLE 1-1: PINOUT I/O DESCRIPTIONS of the data sheet
https://ww1.microchip.com/downloads/en/DeviceDoc/70143E.pdf

are you writing/reading the ports or the latches? have you set/reset the TRIS bits as required? see section 8.0 I/O PORTS
 

Hi,

Ya I have gone through the data sheet of dspic30f controller for I/O ports. I am trying to read/write the latches. But PORTF and PORTG are not reading any values. Even though I set or reset the TRIS bits, PORTF and PORTG are not reading any values. Please let me know the reason for this. The code snippet which I am using to read values of all ports is as follows:


Dio_PortLevelType Dio_ReadPort(Dio_PortType PortId)
{
Dio_PortLevelType Level;
if(State!=INIT)
{
return PORT_FAIL;
}
else
{
/* Error condition for checking the valid portname*/
if(( PortId >='A'&& PortId<'E')|| (PortId >'E'&& PortId<='G'))
{
unsigned int *PortInAddress;
unsigned int Retval;
PortInAddress=0x0000;
Retval=0;
Level=0;
PortInAddress = GETPORTADDR(PortId);
Level=*(PortInAddress);
Retval=Level;
}


else
{
return INVALID_PORT_ID;
}
return PORT_SUCCESS;
}
}

Header file has:
#define GETPORTADDR(x) ((&LATA)+x-10) /*Gets the address of each port data latch and calculates the Port ID(A,B,C,D,E)*/

Please look into it and tell me what changes I need to do with respect to PORTF,PORTG,TRIS registers so that the values which I write to registers can be read.

Thankyou
Swapna
 

I think when writing to port you should make tris as input and while reading the port you have to make tris output.

Post the full code.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top