View previous topic :: View next topic |
Author |
Message |
Richi Guest
|
PIC16F685 - PIC16F690 missing Interrupts |
Posted: Thu Dec 14, 2006 1:39 pm |
|
|
Hi all,
I canīt find the #defines for the interrupt for PortB only the PortA interrupts are available. O.k. I can do it manually....
Also itīs not possible to write #USE FAST_IO(B)
this error occurs: Option invalid Not a valid port: B
Whats wrong? A missing in the Header file, Bug in the compiler or a bug in my brain?
Thanks |
|
|
Richi Guest
|
|
Posted: Thu Dec 14, 2006 1:44 pm |
|
|
Sorry: Version is: 3.235 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Dec 14, 2006 3:08 pm |
|
|
Quote: | Also itīs not possible to write #USE FAST_IO(B)
this error occurs: Option invalid Not a valid port: B |
It compiles OK with PCM vs. 3.249.
If you have PCW or PCWH, check the 16F690 device data with
the Device Editor. Screen shot:
http://www.ccsinfo.com/images/content/device_editor.gif
Check if Port B is enabled in the I/O Ports section. If not,
edit the data to enable it. |
|
|
Richi Guest
|
|
Posted: Fri Dec 15, 2006 4:30 am |
|
|
Thanks PCM, but Iīm using PCM
What about the missing Interrupts on Port B? |
|
|
Ttelmah Guest
|
|
Posted: Fri Dec 15, 2006 5:27 am |
|
|
There isn't a separate PORTB change interrupt. There is a single PORTA/PORTB changed interrupt. This can then be masked to set which port is to be used, using the IOCA/IOCB registers.
So, just set the required bits in these registers for the bits you want to interrupt, and enable the RA interrupt.
Best Wishes |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Fri Dec 15, 2006 5:33 am |
|
|
Quote: | Also itīs not possible to write #USE FAST_IO(B)
this error occurs: Option invalid Not a valid port: B |
I was able to reproduce your error in v3.235. The same program is working in v3.236.
Often errors like this are caused by a wrong configuration in devices.dat, but the date/time of modification for the PIC16F690 configuration is the same in both v3.235 and 3.236 so these are equal and the bug is somewhere else.
The same error also occurs for the PIC16F687, one of the other chips with 4 i.s.o. 8 usable port-B I/O's.
The list of modifications for the v3.xxx versions is no longer on the CCS website but can be checked from http://web.archive.org/web/20060426073030/http://www.ccsinfo.com/devices.php?page=versioninfo.
This specific fix isn't mentioned. |
|
|
Richi
Joined: 15 Dec 2006 Posts: 6
|
|
Posted: Fri Jan 05, 2007 7:33 am |
|
|
Now I got a Update to Version 4.020. Now all interupts are implemented - But not working. Here is the list from .h file PIC16F890 (shortened):
ENABLE_INTERRUPTS(INT_RB) should only enable Bit 3 from INTCON Register but enables all RA Interrupts
ENABLE_INTERRUPTS(INT_RA) should only enable Bit 3 from INTCON Register but enables also all RA Interrupts
#define INT_RB 0xFF0B08
#define INT_RA 0xFF0B08
#define INT_RA0 0x010B08
#define INT_RA1 0x020B08
#define INT_RA2 0x040B08
#define INT_RA3 0x080B08
#define INT_RA4 0x100B08
#define INT_RA5 0x200B08
#define INT_RB4 0x1100B08
#define INT_RB5 0x1200B08
#define INT_RB6 0x1400B08
#define INT_RB7 0x1800B08
The RA interupts are working when simulating, the IOCA register is set correctly.
The RB4 sets Bit0 at IOCA, RB5,RB6;RB7 doesnīt do anything!!
Is it again a compiler error? When are this thing comming right? |
|
|
Richi
Joined: 15 Dec 2006 Posts: 6
|
|
Posted: Fri Jan 05, 2007 9:21 am |
|
|
Now I did following, it sets the registers right:
#asm BSF 0x0B,3 #endasm
#asm BCF 0x0B,3 #endasm
#asm BSF 0x116,5 #endasm
#asm BCF 0x116,5 #endasm
But how do I get the program jump to my ISR when an interrupt occurs?:
#INT_RB
void isr_RB
{
.................
} |
|
|
Ttelmah Guest
|
|
Posted: Fri Jan 05, 2007 10:43 am |
|
|
You already have it.
The answer is the same, as I posted half a dozen posts inthis thread ago. There is _only one port change interrupt_.
look at the interrupts on the data sheet. Read paragraph 14.3.3. Note where it says that an _input change on PORTA or PORTB sets the RABIF_. The INT_RB handler is called whenever a change occurs on either PORTA, or PORTB. Look also at the defines for the interrupts. Note that they are identical for INT_RA, and INT_RB. All that changes are which port bits are flagged as being connected to this interrupt...
Best Wishes |
|
|
Richi
Joined: 15 Dec 2006 Posts: 6
|
|
Posted: Sat Jan 06, 2007 4:50 am |
|
|
Hi Ttlmah,
Iīm sorry to say that but: you are wrong! The right thing is: yes, you can set RABIF with INT_RB and INT_RA. But why does the compiler set all flags in the IOCA. when I set RABIF? How can I set for example only RA3 for an interrupt on change? This is not possible with the compiler and his error.
Look at the registers IOCA and IOCB. Simulate it!
Would the compiler work correctly following should happen:
INT_RB and INT_RA sets the bit 3 of INTCON
INT_RA0 sets the bit 0 of IOCA
INT_RA1 sets the bit 1 of IOCA
INT_RA2 sets the bit 2 of IOCA
INT_RA3 sets the bit 3 of IOCA
INT_RA4 sets the bit 4 of IOCA
INT_RA5 sets the bit 5 of IOCA
INT_RA6 sets the bit 6 of IOCA
INT_RB7 sets the bit 7 of IOCA
INT_RB4 sets the bit 4 of IOCB
INT_RB5 sets the bit 5 of IOCB
INT_RB6 sets the bit 6 of IOCB
I found this solution for the problem:
#define INTOC_ENABLE #asm BSF 0x0B,3 #endasm
#define INTOC_DISABLE #asm BCF 0x0B,3 #endasm
#define INT_RB5_ENABLE #asm BSF 0x116,5 #endasm
#define INT_RB4_ENABLE #asm BSF 0x116,4 #endasm
#INT_RB
void isr_RB()
{
........code.........
}
void main()
{
ENABLE_INTERRUPTS(GLOBAL);
ENABLE_INTERRUPTS(INT_EXT);
ENABLE_INTERRUPTS(INT_TIMER1);
INT_RB4_ENABLE;
INT_RB5_ENABLE; // only RB4 and RB5 are interrupts
ENABLE_INTERRUPTS(INT_RB); // forces the program to jump to ISR
INTOC_DISABLE; // turns of the RABIF bit
*0x96 = 0x00; // sets the IOCA byte to 0 - I donīt want RA Pins as interrupts
for();;
....code....
INTOC_ENABLE
}}
This code enables RB4 and RB5 for interrupts on change, forces the compiler to jump to my ISR when I turn on the bit3 in the INTCON register later in the program and does not allow that another pin causes a jump to my ISR! Please show me how you would do this with only compiler instruction without assembler!
This is a bug in the compiler! |
|
|
Richi
Joined: 15 Dec 2006 Posts: 6
|
|
Posted: Tue Jan 09, 2007 9:17 am |
|
|
Am Iīm right or wrong .... if right I will send a mail to CCS to solve this problem.
If wrong - please show me my error... |
|
|
Ttelmah Guest
|
|
Posted: Tue Jan 09, 2007 10:35 am |
|
|
You are still missing what I actually said.
Simply turn on the interrupt, and set the bits in IOCA/IOCB yourself.
The point is that the interrupt commands in CCS, are aimed at dealing with distinct and separate interrupts. These particular 'set' of interrupt inputs in these chips, are all on the single interrupt, with a large mask of enables. CCS, have attempted a bodge to handle this, but is is just that, a bodge.
Hence, do what I said on Friday 15th December, and just enable the interrupt, and handle the mask yourself. You also don't need to use assembler to set a bit. Just use the #bit definitionj, and turn it on/off.
So, you can define IOCA, and IOCB, as bytes, define the individual bits in these, and turn these on/off as you wish.
Best Wishes |
|
|
|