View previous topic :: View next topic |
Author |
Message |
dnatechnical
Joined: 26 Nov 2009 Posts: 19
|
dspic interrupt uart |
Posted: Mon Jan 11, 2010 2:31 am |
|
|
any one have c code for dspic uart interrupt? |
|
|
dnatechnical
Joined: 26 Nov 2009 Posts: 19
|
|
Posted: Mon Jan 11, 2010 5:20 am |
|
|
need help please
Last edited by dnatechnical on Mon Jan 11, 2010 1:28 pm; edited 1 time in total |
|
|
dnatechnical
Joined: 26 Nov 2009 Posts: 19
|
|
Posted: Mon Jan 11, 2010 5:23 am |
|
|
Code: |
#include <30F6010A.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES PR //Primary Oscillator
#FUSES NOCKSFSM //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES WPSB16 //Watch Dog Timer PreScalar B 1:16
#FUSES WPSA512 //Watch Dog Timer PreScalar A 1:512
#FUSES PUT64 //Power On Reset Timer value 64ms
#FUSES NOBROWNOUT //No brownout reset
#FUSES BORV47 //Brownout reset at 4.7V
#FUSES LPOL_HIGH //Low-Side Transistors Polarity is Active-High (PWM 0,2,4 and 6)
//PWM module low side output pins have active high output polar
#FUSES HPOL_HIGH //High-Side Transistors Polarity is Active-High (PWM 1,3,5 and 7)
//PWM module high side output pins have active high output polarity
#FUSES NOPWMPIN //PWM outputs drive active state upon Reset
#FUSES MCLR //Master Clear pin enabled
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOCOE //Device will reset into operational mode
#FUSES ICSP1 //ICD uses PGC1/PGD1 pins
#FUSES RESERVED //Used to set the reserved FUSE bits
#use delay(clock=12000000)
#include <stdio.h>
#use rs232(UART1,baud=9600,parity=E,bits=8,errors)
char c;
#int_RDA
void RDA_isr(void)
{
c=fgetc();
clear_interrupt(int_RDA);
}
void main()
{
setup_spi(SPI_SS_DISABLED);
setup_spi2(SPI_SS_DISABLED);
setup_wdt(WDT_Off);
enable_interrupts(INT_RDA);
// TODO: USER CODE!!
loop:
delay_ms(200);
goto loop;
}
receive interrupt is not generated |
|
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Tue Jan 12, 2010 1:26 am |
|
|
How do you determine, that no interrupt is generated? There's no interrupt action in your code, except reading the data.
clear_interrupt(int_RDA) is not required. setup_spi(SPI_SS_DISABLED) and setup_spi2(SPI_SS_DISABLED)
are enabling the SPI interfaces, apparently unintended.
But the UART1 RX interrupt should work anyway, I think. |
|
|
dnatechnical
Joined: 26 Nov 2009 Posts: 19
|
|
Posted: Tue Jan 12, 2010 12:35 pm |
|
|
I'm using debugger(pickit 3) to check it.
I set break point at clear interrupt, so I can check data.
I'm sending data through com port via max232.
There no change in flag bit or U1RXREG.
Yes I know setup_spi(SPI_SS_DISABLED) and setup_spi2(SPI_SS_DISABLED)
are enabling the SPI interfaces, apparently unintended.
But I use ccs project wizard. Its generated by it, so I keep it as it is. |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1611 Location: Central Illinois, USA
|
|
Posted: Wed Jan 13, 2010 12:22 am |
|
|
Weird.
Every time I see a goto in C my brain goes "arf??"
Is it just me?
I know it's legal, but it just seems so BASIC. :P
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Wed Jan 13, 2010 12:36 am |
|
|
Quote: | But I use ccs project wizard. Its generated by it, so I keep it as it is. | Thank's for clarifying, I never use the project wizard. I finally understood, where these rubish statements come frome.
Quote: | There no change in flag bit or U1RXREG. |
Sounds like no data ever arrives at the UART. |
|
|
dnatechnical
Joined: 26 Nov 2009 Posts: 19
|
|
Posted: Wed Jan 13, 2010 10:40 am |
|
|
Right. There is no data receive from uart.
Even if I check data through serial port monitor at end of dspic rx pin
I receive some data but interrupt is not generated.
Anyone have idea ?
thanks |
|
|
|