View previous topic :: View next topic |
Author |
Message |
digisol
Joined: 02 Jul 2005 Posts: 11 Location: Hermosillo, Sonora, Mexico
|
RDA_isr() PIC16F648A |
Posted: Fri Aug 17, 2007 7:53 pm |
|
|
Code: | I have problems putting to work RDA_isr(), here is my code (so simple!)
#use delay(clock=10000000,RESTART_WDT)
#fuses WDT,HS, NOPUT, NOPROTECT, BROWNOUT, MCLR, NOLVP, NOCPD
#define EEPROM_SCL PIN_A0
#define EEPROM_SDA PIN_A1
#define TOUCH_DEVICE PIN_B0
#define RTC_SCLK PIN_B4
#define RTC_IO PIN_B5
#define RTC_RST PIN_B6
#use rs232(baud=19200,parity=N,xmit=PIN_B2,rcv=PIN_B1,bits=8,restart_wdt)
RDA_isr()
{
Data = getch();
putc(Dato);
}
main()
{
setup_timer_0(RTCC_INTERNAL);setup_wdt(WDT_288MS);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
rtc_init();
init_ext_eeprom();
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
while(1) {;}
}
I want to use DS1302, 24C65 and touch, once RDA_int works
Data = getc() works within main, but not within RDA_int
[code][/code] |
Best regards |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Aug 17, 2007 8:41 pm |
|
|
You need to tell compiler that the RDA_isr() routine is for the RDA
interrupt. This is done by adding the statement shown in bold below,
in that exact position.
Quote: |
#int_rda
RDA_isr()
{
Data = getch();
putc(Dato);
} |
Also, you don't have any code to restart the Watchdog in your main
loop, so it's going to reset your PIC. I suggest that you change your
fuses to 'NOWDT', at least for now. |
|
|
digisol
Joined: 02 Jul 2005 Posts: 11 Location: Hermosillo, Sonora, Mexico
|
|
Posted: Fri Aug 17, 2007 9:08 pm |
|
|
Code: | I forgot to put this line in the post
#int_RDA it is included in the code, project wizard did it.
actualy in the main there is switch() like
while(1)
{
switch(Data)
{
case 'A' : printf("You press an A..."); restart_wdt();
case 'B' : printf("You press an B..."); restart_wdt();
case 'C' : printf("You press an C..."); restart_wdt();
.
.
.
}
}
with no results |
I tested the same code with a PIC16F84 and it worked the very first time!
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Aug 17, 2007 9:18 pm |
|
|
Try a very simple test program, as shown below. If it doesn't work,
then post your compiler version.
Code: | #include <16F648A.h>
#fuses HS, NOWDT, PUT, BROWNOUT, NOLVP, MCLR
#use delay(clock=10000000)
#use rs232(baud=19200, xmit=PIN_B2, rcv=PIN_B1, ERRORS)
#int_rda
void rda_isr(void)
{
char c;
c = getc(); // Get character from PC
putc(c); // Send it back to the PC
}
//========================
void main()
{
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
while(1);
} |
|
|
|
digisol
Joined: 02 Jul 2005 Posts: 11 Location: Hermosillo, Sonora, Mexico
|
|
Posted: Fri Aug 17, 2007 9:36 pm |
|
|
NOTHING!
does not work!
|
|
|
digisol
Joined: 02 Jul 2005 Posts: 11 Location: Hermosillo, Sonora, Mexico
|
|
Posted: Fri Aug 17, 2007 9:42 pm |
|
|
Can any of the drivers like ds1302, 24C65 or touch have conflict with RDA_isr()?
Sorry! I forgot to include the compiler version it is 3.212
In case this version has bugs, what do I need to do?
Buy a new version? or may I have like a patch or something?
Very best regards |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Aug 17, 2007 9:42 pm |
|
|
1. What board are you using ? Did you build it yourself or did you buy it ?
2. What is the Vdd voltage for the PIC ? 3.3v or 5.0v ?
3. Do you know that this board works ? Have you ever made the PIC
blink an LED ?
4. Post your compiler version. It's a number in this format: x.xxx
such as 3.249, 4.013, 4.050, etc. |
|
|
digisol
Joined: 02 Jul 2005 Posts: 11 Location: Hermosillo, Sonora, Mexico
|
|
Posted: Fri Aug 17, 2007 9:49 pm |
|
|
I am using a brand new protobord
it works with 5.0 V with 100 uF , and 0.1 cap filter in Vcc
I know that it works because if using no interrupt I got input and output serial data along with some other beeps and leds using getc within main()
Regards! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Aug 17, 2007 11:57 pm |
|
|
I compiled the test program that I posted above for both version 3.212
and 4.049. The .LST files are very similar and the registers look correct.
I think the code should work.
Therefore, I think the problem is in your hardware.
1. Post the manufacturer and model number of your protoboard.
2. Post the connections between your protoboard and your PC for
the RS-232. Is it done with a manufactured cable, or did you make it ?
If you made, post the list of connections to the PC in detail.
Answer both questions above. |
|
|
digisol
Joined: 02 Jul 2005 Posts: 11 Location: Hermosillo, Sonora, Mexico
|
|
Posted: Sat Aug 18, 2007 9:49 am |
|
|
manufacturer of protoboard is ELECTRONICS RESOURCES LTD
I can't see a model number of protoboard
Connection to PC is PIC to MAX232CPE with tantalum caps and +9V in pin 2 of MAX232, and -9V in pin 6 of MAX232 and then 3 wires to a DB-9 male to a manufactured cable
Coneccions of DB9 and MAX232 are:
- DB9.5 to protoboarda ground
- DB9.2 to pin 7 of MAX232
- DB9.3 to pin8 of MAX232
- pin 9 of MAX232 to B.1 of PIC
- Pin 10 of MAX232 to B.2 of PIC
Please note that everything works, LED's, serial port, etc BUT with NO interrupt
Also i found info about problems with PIC16F648A. See this:
http://www.techreplies.com/microprocessors-55/critical-problems-pic-16f648a-340970/
I will change the PIC16F648 to PIC16F627-04 and let you know what happened
Very best regards
|
|
|
Ttelmah Guest
|
|
Posted: Sun Aug 19, 2007 3:43 am |
|
|
Let's look at the original code as posted.
Problems:
1) You are reading data into 'data', but outputting from 'dato'. Not a good start.
2) No declaractions are given for either variable.
3) You will watchdog. The 'restart_wdt' ability, makes the compiler add code to reset the watchdog when getc, 'waits for a character'. Inside the interrupt, this will never happen....
4) Even if the code was working, it'd go wrong, if characters don't arrive at least every 288mSec (or slightly less for safety). Remember that handling a watchdog event, takes time (a lot with the initialisation code included), and charaters will be missed during the watchdog.
Now, given these errors, did you really type PCM_programmers code in _exactly_ as it is, with _no_ changes?. This code _works_ with 3.212, and if it doesn't, then you have a hardware problem somewhere.
Best Wishes |
|
|
digisol
Joined: 02 Jul 2005 Posts: 11 Location: Hermosillo, Sonora, Mexico
|
|
Posted: Tue Aug 21, 2007 1:57 pm |
|
|
1.- Sorry Dato = data (mistype)
2.- Dato is defined as global. char Dato;
3.- Not sure about restart_wdt() with getc, does it means the I rather choose
not to use WDT or I will loose interrupts every time?
Not sure of what does "did you really type PCM_programmers code in
_exactly_ as it is, with _no_ changes?" means
what if I use a single instrucction code? like...
#asm
clrwdt
#endasm
Thanks a lot! |
|
|
digisol
Joined: 02 Jul 2005 Posts: 11 Location: Hermosillo, Sonora, Mexico
|
|
Posted: Tue Aug 21, 2007 2:10 pm |
|
|
both "restart_wdt()" and "#asm clrwdt #endasm" are one instruccion only
Sorry I did not got it. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Aug 21, 2007 2:32 pm |
|
|
Here is the website for Electronic Resources Ltd.
It shows the only "protoboards" that they sell are breadboards:
http://www.erusa.com/catalog.asp?Family=Bread+Boards&Category=All
These boards require that you make all connections with jumpers.
Is this the type of board that you're using for this project ?
I was thinking that you had a factory built board like this:
http://www.units.it/~atmocube/presentazioni/galilei_07/picdem2plus.JPG
This is a large photo of a Microchip Picdem2-Plus that I found on the net.
Have you ever made the PIC do anything, such as blinking an LED ?
In other words, do you know that your PIC circuit works at all ? |
|
|
digisol
Joined: 02 Jul 2005 Posts: 11 Location: Hermosillo, Sonora, Mexico
|
|
Posted: Wed Aug 22, 2007 3:32 am |
|
|
Yes! I have one of those protoboards of link.
In my first post I said "Dato = getc() works within main, but not within RDA_isr() ", I have now a 'large' program for this PIC, I manage to make it without interrupts.
Memory usage: ROM=60% RAM=14% - 21%
I can not put to work RDA_isr(), not even with the smallest code
I will finish the projetc with no RDA_isr()
Best regards! |
|
|
|