Hi, can someone please give me some guidance on handling multiple interrupts. I have a single interrupt working fine.
Could you also tell me what this 'if' statement is doing and its 'logic':
if(pir1 & (1<<RCIF))
Cheers!
Dave
Multiple interrupts
Moderator: Benj
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Multiple interrupts
Hi Dave,
The code is doing this....
if a byte has been received on the UART but not processed....
or
if register pir1 bit RCIF is set....
You can see the details of the pir1 register listed in the device datasheet. Simply do a search for pir1 or RCIF inside the PDF viewer.
The code is doing this....
if a byte has been received on the UART but not processed....
or
if register pir1 bit RCIF is set....
You can see the details of the pir1 register listed in the device datasheet. Simply do a search for pir1 or RCIF inside the PDF viewer.
RCIF: USART Receive Interrupt Flag bit
1 = The USART receive buffer is full
0 = The USART receive buffer is empty
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Multiple interrupts
Thanks Benj,
Yes I understand the usart but not quite sure about this bit, excuse the pun!
(1<<RCIF)? as in if( pir1 &(1<<RCIF))
Why not if( pir1.RCIF)
Sorry if I am not making myself clear!
BW
Dave
Yes I understand the usart but not quite sure about this bit, excuse the pun!
(1<<RCIF)? as in if( pir1 &(1<<RCIF))
Why not if( pir1.RCIF)
Sorry if I am not making myself clear!
BW
Dave
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Multiple interrupts
Hi Dave,
Both lines of code do exactly the same thing in BoostC so you could use either or.
However our code also supports the HiTech compiler which requires this type of dot notation.
if( PIR1bits.RCIF)
Which is why we do not use dot notation everywhere in our code.
Also there have been official reports of dot notation now working in some cases due to silicone and compiler bugs. The left shift approach does not seem to have these failings though may be slightly less efficient.
Both lines of code do exactly the same thing in BoostC so you could use either or.
However our code also supports the HiTech compiler which requires this type of dot notation.
if( PIR1bits.RCIF)
Which is why we do not use dot notation everywhere in our code.
Also there have been official reports of dot notation now working in some cases due to silicone and compiler bugs. The left shift approach does not seem to have these failings though may be slightly less efficient.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel