View previous topic :: View next topic |
Author |
Message |
suhail
Joined: 19 May 2011 Posts: 3
|
#int_rda does not fire in dsPIC30f6014a |
Posted: Thu May 19, 2011 11:44 pm |
|
|
The code below without the ISR works fine
Code: |
#include<30f6014a.h>
#device adc=10
#fuses XT_PLL8, PRPLL
#use delay(clock=80M,oscillator=10M)
#use rs232(baud=115200,parity=N,xmit=PIN_F3,rcv=PIN_F2,bits=8)
#include<lcd.h>
unsigned char input[10];
void main(void){
while(1) {
input[0] = getc();
putc(input[0]);
}
}
|
But when I include the #int_rda, the service routine does not work. A similar code works fine with 16f877a chip.
The modified code is
Code: |
#int_rda
void serial_interrupt(){
input[0] = getc();
}
void main(void) {
enable_interrupts(INT_RDA);
enable_interrupts(INTR_GLOBAL);
while(1) {
putc(input[0]);
}
}
|
The char is sent but not received. Many thanks for the help.
Dr suhail |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Fri May 20, 2011 2:40 am |
|
|
I think you need to look at #pin select. On this chip the UART is re-mappable to two sets of pins. The compiler needs to be told that you want to use the UART on the primary pins.
Best Wishes |
|
|
suhail
Joined: 19 May 2011 Posts: 3
|
|
Posted: Thu May 26, 2011 10:54 pm |
|
|
Many thanks for the reply. I think you are right. I tried the following commands
Code: |
#pin_select U1Tx=PIN_F3
#pin_select U1Rx=PIN_F2
|
by compiler version is 4.065
The error that was generated was
error 7:... Invalid pre-processor directive Invalid pin
I think the version does not support pin_select directive. Is there a way around ?
regards |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Fri May 27, 2011 2:26 am |
|
|
What compiler version are you on?.
I just tried a fractionally modified code, on 4.118, and the RDA interrupt fires OK.
Code: |
#use rs232(baud=115200,parity=N,UART1,bits=8)
unsigned char input[10];
int1 have_char=FALSE;
#int_rda
void serial_interrupt(){
input[0] = getc();
have_char=TRUE;
}
void main(void) {
enable_interrupts(INT_RDA);
enable_interrupts(INTR_GLOBAL);
do {
if (have_char) {
have_char=FALSE;
putc(input[0]);
}
} while(TRUE);
}
|
Best Wishes |
|
|
suhail
Joined: 19 May 2011 Posts: 3
|
|
Posted: Sun May 29, 2011 5:56 am |
|
|
many thanks for the reply and effort.
my ver is 4.065
i think i did try UART1 option... but not sure...
will try it next week and let you know..
many thanks and regards |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Sun May 29, 2011 9:37 am |
|
|
I suspect the version may be the problem. 4.065, is 'borderline' on when V4, started to work reasonably completely, and there were a few threads at the time about problems with the DsPic's, and getting their UART's to work. In some cases using the UART1 option did help, but not for all...
I haven't got a PCD, back this far, but 4.099, is not handling the interrupts the same way as the later compilers, suggesting problems may well be present here.
Best Wishes |
|
|
|