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 support@ccsinfo.com

conflict between int_rda and spi, how to stop int_rda?

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



Joined: 30 Jan 2004
Posts: 7

View user's profile Send private message

conflict between int_rda and spi, how to stop int_rda?
PostPosted: Fri Jun 18, 2004 12:27 pm     Reply with quote

Hello,

I've to control the interrupt "int_rda". How can I stop the INT and than start again?

// code example
#include <18F452.h>
#fuses HS,NOWDT,NOPROTECT,NOBROWNOUT,NOPUT
#device ADC=10
#device *=16
#device ICD=TRUE
#use delay(clock=20000000)
// #use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7, parity=N,bits=8,stream=, DISABLE_INTS)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7, parity=N,bits=8,stream=)

...

INTREG_RS232 = 0; // #bit INTFLAG_RS232 = 0xf9e.5
// The INT stops correct

Write_Block_512(max_mmc_count); // SPI routine

INTREG_RS232 = 1;
// !!! The INT doesen't work again ????


Has anybody an idea, how the INT can be reactivated??

Thanks a lot!!

Regards
Petar


...
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jun 18, 2004 1:27 pm     Reply with quote

I suspect you are getting an overrun error in the hardware USART.

To fix this problem add the errors directive to the end of the statement:
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)


Also, two other things:

1. You don't need #device *=16 with the 18-series PICs.
It's only needed with the 16-series PICS (16F877, etc.)

2. You very likely need to add NOLVP to the end of your #fuses
statement.
Ttelmah
Guest







Re: conflict between int_rda and spi, how to stop int_rda?
PostPosted: Fri Jun 18, 2004 3:00 pm     Reply with quote

Petar wrote:
Hello,

I've to control the interrupt "int_rda". How can I stop the INT and than start again?

// code example
#include <18F452.h>
#fuses HS,NOWDT,NOPROTECT,NOBROWNOUT,NOPUT
#device ADC=10
#device *=16
#device ICD=TRUE
#use delay(clock=20000000)
// #use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7, parity=N,bits=8,stream=, DISABLE_INTS)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7, parity=N,bits=8,stream=)

...

INTREG_RS232 = 0; // #bit INTFLAG_RS232 = 0xf9e.5
// The INT stops correct

Write_Block_512(max_mmc_count); // SPI routine

INTREG_RS232 = 1;
// !!! The INT doesen't work again ????


Has anybody an idea, how the INT can be reactivated??

Thanks a lot!!

Regards
Petar


...

What you are doing, is _not_ stopping the interrupt.
You are confusing the 'interrupt enable' flag, with the interrupt flag itself. If PIE1.5, is set, and the interrupt is enabled, the interrupt handler should allready have been called.
What happens is that by clearing this flag, you are telling the UART, that the received character has been 'handled' by you, without taking this character from the buffer. On the next character being received, you will generate a comms overrun error, and this hangs the UART, till it is reset.
First, add 'ERRORS' to your RS232 declaration (which will clear this error when getc is used).
Second, use the 'disable_interrupts(INT_RDA)' command (and the corresponding 'enable_interrupts' command), to stop and start the interrupt. This way, the interrupt flag will remain set. Then if there is a comm overflow, the handler will be called, and clear the error.

Best Wishes
Sergio



Joined: 16 Oct 2003
Posts: 11
Location: Arkansas, USA

View user's profile Send private message

PostPosted: Fri Jun 18, 2004 7:30 pm     Reply with quote

This is what I do...

To stop:
bit_clear(RCSTA, 7) //Serial port disabled

To re-start;
bit_set(RCSTA, 7); // Serial port enabled
bit_clear(RCSTA, 4); // By clearing CREN you clear overrun error
// on OERR
bit_set(RCSTA, 4); // Enables mode again

Cheers
_________________
Sergio
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