CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

RS232 communication (PIC16F877)

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jun 10, 2007 12:51 pm     Reply with quote

Quote:

#include "16f877.h"
#include <STDLIB.H>
#define HIGH_START 114
#fuses HS,NOWDT,NOPROTECT, NOLVP

Add NOLVP to your #fuses statement as shown in bold.


Quote:

#INT_Rb
void rs232(void) {
char chr;

disable_INTERRUPTS(GLOBAL);



ENABLE_INTERRUPTS(GLOBAL); }
}

You don't have to enable/disable global interrupts in any interrupt routine.
The PIC automatically does this for you in hardware. In fact, it's
dangerous to re-enable Global interrupts inside an interrupt routine.
Nested interrupts are not supported for the 16F series PICs.
Delete those two lines.


Quote:

Is it wrong to use INT_RB?

The standard method is to use INT_EXT (on pin B0) for the Rx pin
of a software UART.
Wieger



Joined: 10 Jun 2007
Posts: 2

View user's profile Send private message

PostPosted: Sun Jun 10, 2007 1:25 pm     Reply with quote

Thanks, I hope this will help. Smile

But what exactly is the effect of the NOLVP (no low-voltage programming) option (or the missing of it)?

And why is using INT_EXT the standard method?
arunb



Joined: 08 Sep 2003
Posts: 492
Location: India

View user's profile Send private message Send e-mail

RE:
PostPosted: Sun Jun 10, 2007 2:38 pm     Reply with quote

Hi,

Technically it is possible to use INT_EXT or INT_RB for detecting USART characters, I have also used them in my applications, but I I have found that they work well in low baud rates only, as the baud rate is increased, more and more garbage is received. Also you must put a delay_us() statement in the interrupt routine.

for eg:

int_ext
usart2()
{

delay_us(100)
cData=getc(UART2_STERAM);

}

thank
arunb
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Sun Jun 10, 2007 5:43 pm     Reply with quote

To use PB on change interrupt feature be aware that:

1) Any pin PB4...7 will fire the interrupt. Be sure that all the 3 "unused"
PortB pins should be in steady state.

2) It is the programmer responsibility to clear the interruption, it is not cleared
"automatically" like another interrupts.
To clear the interrupt, you must do a portB read operation inside the interrupt.
Add: x = portB;
inside the interrupt handler, if not you will receive only one of the expected char.


Humberto
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Jun 11, 2007 12:53 am     Reply with quote

Quote:
But what exactly is the effect of the NOLVP (no low-voltage programming) option (or the missing of it)?
95% of the chip programmer devices are of the high voltage type.
The low voltage programmers require the PGM (B3 on the 16F877) so this can't be used in your application for other purposes. With LVP active an (accidental) low voltage on the PGM input activates the programming mode stalling your processor. Setting the NOLVP fuse saves you these potential problems.

Your protocol() function is calling printf. Calling printf from inside an interrupt routine shouldn't be done as it takes a long time and you are going to miss received data.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group