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.

16F877A - USART - PORTD problem

Status
Not open for further replies.

ZynT

Newbie level 4
Joined
Jun 28, 2009
Messages
7
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,338
Hi everybody;

I've built a test circuit. It has an LCD display on PORTD besides serial comm. with computer.
I've only used the LCD before and tested a program. It works well.
After that, I've initialized the RCSTA and TXSTA to communicate on serial bus, but the LCD has obstacled.
Serial comm is working but LCD is not working properly.
I've deleted 3 lines, LCD has worked again. But i dont use receive and transmit interrupt.
I think RCIE and TXIE bits effect the PORTD due to LCD_DATA_PORT is PORTD


**broken link removed**
**broken link removed**

What the mention wrong about that?

Best regards
 

Hi everybody;

I've built a test circuit. It has an LCD display on PORTD besides serial comm. with computer.
I've only used the LCD before and tested a program. It works well.
After that, I've initialized the RCSTA and TXSTA to communicate on serial bus, but the LCD has obstacled.
Serial comm is working but LCD is not working properly.
I've deleted 3 lines, LCD has worked again. But i dont use receive and transmit interrupt.
I think RCIE and TXIE bits effect the PORTD due to LCD_DATA_PORT is PORTD


**broken link removed**
**broken link removed**

What the mention wrong about that?

Best regards


Hi,

Port D and the USART on PortC do not confict in any way with valid coding.

Have not gone though your code in any detail as the most obvious error is the ISR.

Have a read from the datasheet, you must use CONTEXT saving.
When an Interruot occurs you must save the key registers like W and Status so when you return from the ISR your info is restored.

In the ISR your first instuction is RETFIE, that sends it back to where it came from.
RETFIE is the last instruction in the ISR

Also once in the ISR you should execute the code quickly incase other interrupts are stacking up.
You seem to be executing most of your code from within it, that will lead to futher problem.

Have a look at things again and try and get most of your code in the MAIN loop, not the ISR.

If you still have problems show your revised code post it again, but use the # CODE tags .
 

I've done context saving. I'll edit the code completely in one file and post it.
see you.
thanks.
 

Hi,

Just noticed your config code is a number, and not a value I remember as valid.

Much better to use the Config like this, showing the exact details.

Code:
	__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _HS_OSC & _WRT_OFF & _LVP_OFF & _CPD_OFF
 

Hi there;

I've tried to clean the code and got advance.
The problem is TXEN bit. It is set by RS_INIT routine. It creates an interrupt and program is branched to the interrupt continuously.
I think it must be set only transmitting process, right?
I thought before, by setting TXEN, i can get an interrupt to transmit the next byte. I think this is wrong while not transmitting.
To add the code here is very difficult due to linux and windows new line and return carriage compatibility. By copy-paste, all lines is in one line.

anyway, the solution of my problem is TXEN.

wp100 thanks for your interest. i like to use only one hex code to configure the config word. your way is also well. :)
 

Hi there;

I've tried to clean the code and got advance.
The problem is TXEN bit. It is set by RS_INIT routine. It creates an interrupt and program is branched to the interrupt continuously.
I think it must be set only transmitting process, right?
I thought before, by setting TXEN, i can get an interrupt to transmit the next byte. I think this is wrong while not transmitting.
To add the code here is very difficult due to linux and windows new line and return carriage compatibility. By copy-paste, all lines is in one line.

anyway, the solution of my problem is TXEN.

wp100 thanks for your interest. i like to use only one hex code to configure the config word. your way is also well. :)



Hi,

Have a look at this good tutorial and these examples on the Usart and LCD

http://www.winpicprog.co.uk/pic_tutorial7.htm download and see the code examples and see #7.7 which is the hardware Usart for the 876/877 chips.

http://www.winpicprog.co.uk/pic_tutorial3.htm
 
  • Like
Reactions: ZynT

    ZynT

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top