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.

pic16f877a microcontroller port driver implementation

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,
M a newbie.M working on pic16f877a microcontroller port driver.M using Hitech C compiler.I have initialized all the ports(PORTA,PORTB,PORTC,PORTD,PORTE).But now m finding difficulty in reading and writing ports.Please help me with the logic to read/write ports.




Thanx in advance
 

it is very simple to understand the ports concept. first of all read the datasheet ports section. then give TRISB0 = 1 for input TRISB0 = 0 for output.
 

Hi,
Ya I have gone through.I am implementing the port driver and I have faced a problem in it.The pins RB7 and RC7 are always high. Is it connected to pull up resistors?I din't find anything about the pins level in the data sheet. RC7 acts as RX/DT pin for the micro controller. Please tell me why that pin is high always while executing.



Thanks
 

Hi all,

I have been working on the uart module of pic16f877a micro controller. I have gone through the registers used and I am aware of the configuration to use 8 bit communication. But these registers do not include start and stop bits in their design . Please let me know how am I supposed to append start/stop bits with the 8 data bits?And also how to read and write the 8-bit data from registers?


Thank you
 

in serial communication trough the usart module of PIC microcontrollers (or any other microcontroller), you donot want to send the start and stop bits. the controller will do that essential thing in that comminication you just need to set the RCSTA register and TXSTA register. and load the baud rate generator value to the SPBRG register. then check for any transmission is in progress; if not place your required 8 bit data in TXREG register. that's all. the communication over
 

Hi all,
M a newbie.M working on pic16f877a microcontroller port driver.M using Hitech C compiler.I have initialized all the ports(PORTA,PORTB,PORTC,PORTD,PORTE).But now m finding difficulty in reading and writing ports.Please help me with the logic to read/write ports.




Thanx in advance

Who is M?
Anyway. The pins RB0-RB7, RC0-RC7, and RD0-RD7 are digital I/O pins. The pins CCP1 and CCP2, which share locations with RC1 and RC2, can be used for a PWM signal . The pins AN0-AN7 are for analog I/O . TX and RX are for debugging I/O .

If you want to set PORTA of PIC16F877/877A/874, You have to use some extra register configurations with ADCON1 and COMCON registers .

COMCON=0x07 disables the comparators
ADCON1 = 0x06 makes all the pins of PORTA as Digital I/O by default it is Analog


PORT B and the TRIS B Registers

PORT B is also an 8 bit bi-directional PORT. Its direction controlled and maintained by TRIS B data direction register. Setting the TRIS B into logic ‘1’ makes the corresponding “PORT B” pin as an input. Clearing the TRIS B bit make PORT B as an output. Three pins of PORT B are multiplexed with the In-Circuit Debugger and Low-Voltage Programming function: RB3/PGM, RB6/PGC and RB7/PGD for performing its alternate functions.​

PORT C and the TRIS C Registers

PORT C is an 8-bit wide, bidirectional PORT which controlled and maintained by TRIS C data direction register. Setting a TRIS C bit (= 1) will make the corresponding PORT C pin an input (i.e., put the corresponding output driver in a High-Impedance mode). Clearing a TRIS C bit (= 0) will make the corresponding PORT C pin an output PORT C is also multiplexed with several peripheral functions. PORT C pins have Schmitt Trigger input buffers.
When enabling peripheral functions, more care should be taken in defining TRIS bits for each PORT C pin as compared to other. Some peripherals override the TRIS bit to make a pin an output, while other peripherals override the TRIS bit to make a pin an input. Since the TRIS bit override is in effect while the peripheral is enabled, read-modify write instructions (BSF, BCF, and XORWF) with TRISC as the destination, should be avoided. The user should refer to the corresponding peripheral section for the correct TRIS bit settings.​


PORT D and TRIS D Registers


PORT D is an 8-bit PORT with bi-directional nature. This port also with Schmitt Trigger input buffers, each pin in this PORT D individually configurable as either input or output. PORT D can be configured as an 8-bit wide microprocessor PORT (functioning as Parallel Slave PORT) by setting control bit, PSPMODE ((TRISE<4>). In this mode, the input buffers are TTL.​


PORT E and TRIS E Registers

PORT E has only three pins (RE0/RD/AN5, RE1/WR/AN6 and RE2/CS/AN7) which are individually configurable as inputs or outputs. These pins controllable by using its corresponding data direction register “TRIS E”. These pins also have Schmitt Trigger input buffers. The PORT E pins become the I/O control inputs for the microprocessor PORT when bit PSPMODE is set. In this mode, the user must make certain that the TRIS E bits are set and that the pins are configured as digital inputs. Also, ensure that ADCON1 is configured for digital I/O. In this mode, the input buffers are TTL.
TRISE register which also controls the Parallel Slave PORT operation. PORT E pins are multiplexed with analog inputs. When selected for analog input, these pins will read as ‘0’s. TRIS E controls the direction of the RE pins, even when they are being used as analog inputs. The user must make sure to keep the pins configured as inputs when using them as analog inputs.​
 
Last edited:

Hi all,

Thanks for your replies. I have set the RCSTA and TXSTA registers and also the SPBRG register for suitable baudrate.I am making use of interrupts for transmission and reception. I have loaded the TXREG with the data and m checking for the data to be received in RCREG. But my RCREG is not gettin updated with the data. And also RCIF is always reset which indicates data is not received by RCREG. Please help me with the logic to transmit data from TXREG to RCREG.


Thankyou in advance
 

RCREG is the register to receive data from external devices. Or otherwise shorted the rx and tx lines of the micro-controller. If any data received the bit RCIF must be get high.
 

Hi,

How do we short rx tx lines of microcontroller?Actually I nedd to send and receive data from the hyperterminal(PC).Please let me know how to establish communication?My RCIF is not going high atall though I have set RCIE and transmitted data to TXREG.In some cases when I run the program TXREG and RCREG are takin random values.What is the reason for that?And also please let me know how to establish communication with hyperterminal?Please help!!It is urgent!!


Thankyou
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top