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 CCS Technical Support

dspic interrupt uart

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



Joined: 26 Nov 2009
Posts: 19

View user's profile Send private message

dspic interrupt uart
PostPosted: Mon Jan 11, 2010 2:31 am     Reply with quote

any one have c code for dspic uart interrupt?
dnatechnical



Joined: 26 Nov 2009
Posts: 19

View user's profile Send private message

PostPosted: Mon Jan 11, 2010 5:20 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Jan 11, 2010 5:23 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jan 12, 2010 1:26 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jan 12, 2010 12:35 pm     Reply with quote

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: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Wed Jan 13, 2010 12:22 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jan 13, 2010 12:36 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jan 13, 2010 10:40 am     Reply with quote

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
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