View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jun 10, 2007 12:51 pm |
|
|
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
|
|
Posted: Sun Jun 10, 2007 1:25 pm |
|
|
Thanks, I hope this will help.
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
|
RE: |
Posted: Sun Jun 10, 2007 2:38 pm |
|
|
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
|
|
Posted: Sun Jun 10, 2007 5:43 pm |
|
|
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
|
|
Posted: Mon Jun 11, 2007 12:53 am |
|
|
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. |
|
|
|