Page 1 of 1

16f1939/16f1938 missing port interrupts

Posted: Thu Nov 24, 2011 9:23 am
by brandonb
on this device the port interrupts are missing(int on change), is there an updated .fcd file to correct this on the 16f1938 and 16f1939 chips? i have a 4 day weekend and it would be nice to be able to use these chips with the above potential :D

Re: 16f1939/16f1938 missing port interrupts

Posted: Sat Nov 26, 2011 5:41 pm
by brandonb
matrix whats the expectation on this

Re: 16f1939/16f1938 missing port interrupts

Posted: Sat Nov 26, 2011 8:57 pm
by Spanish_dude
Any chance you'd use a C code block ?

Re: 16f1939/16f1938 missing port interrupts

Posted: Sat Nov 26, 2011 9:15 pm
by brandonb
hey spanish dude (cool name) i dont know anything about assembly or C language, thats why i got flowcode :D i was thinking about using the datasheet to configure the registers but since the port interrupt is not an option i dont see how it would do anything since i wouldnt have a place to draw an interrupt macro.... im probably way off course on my reasoning since i really dont know what im talking about only guessing really, can you explain your thinking, im interested in learning as much as possible with pic and flowcode

Re: 16f1939/16f1938 missing port interrupts

Posted: Sat Nov 26, 2011 10:11 pm
by Spanish_dude
but since the port interrupt is not an option i dont see how it would do anything since i wouldnt have a place to draw an interrupt macro
Actually, I thought about the same issue... :/

Configuring the registers to enable the port interrupt shouldn't be that hard to write in C code, but you do not have an interrupt function to jump to.
I'm not good at modifying an FCD file (actually I never really tried, but looks a bit complicated :P) but I may have a little workaround.
This is certainly not the best way to do it but it's the only idea I have right know :mrgreen: .
Enable something like a timer interrupt or other interrupt just so you can access the interrupt macro.
Adding an if-statement to ONLY execute the interrupt macro when a PORT interrupt has been triggered.
Something like this :
if timer interrupt isn't triggered then
execute PORT IO interrupt code
else if timer interrupt triggered then
reset timer interrupt

Re: 16f1939/16f1938 missing port interrupts

Posted: Sun Nov 27, 2011 6:37 am
by brandonb
hey spanish dude, i'll have to attempt that tommorrow, i havent done anything like that before, out of curiosity what chips do you use that have program memory around 28kb that work good with flowcode... im gonna buy some 18f2685's but at $12 a pop its a bit overkill with 96kb, i want to make a engine controller out of one of those, hopefully in v5 they have all this stuff cleared up

Re: 16f1939/16f1938 missing port interrupts

Posted: Sun Nov 27, 2011 12:53 pm
by Spanish_dude
The PICs I used so far are the 16F84A, 16F88, 16F877A, 18F2455 (24kbytes flash), 18F2550 (32kbytes flash) and 18F4455 (24kbyte flash).
I also have some 12F675 but I haven't used them yet.

I don't know their price. I can have free "samples" from microchip using my high school e-mail.
If you have an e-mail not ending with "hotmail", "gmail", ... you can ask for free samples too.

They usually take 1 or 2 weeks to get here but I saved a lot of money.
(The first time I bought a 16F877A from an electronics store I payed 12€ for it. That's a rip-off.)

The staff is working really hard on Flowcode v5 and I'm sure it'll be awesome.

Nicolas

Re: 16f1939/16f1938 missing port interrupts

Posted: Mon Nov 28, 2011 5:53 am
by brandonb
thanks spanish dude, on second thought the 16f1939 and 16f1938 are the perfect chips for what i need, i tryed to do what you suggested with changing the registers but couldnt get it to work.... im hoping that matrix would see this post and fix these two chips for me to be able to use the port interrupts in the normal fashion, then i'll move up to the 18f4685..... something that i could do with equel result would be on hardware since i use 5 switches i could keep my switches hooked up to the pins they are on then run diodes from each switch to pin B0 which is an external int on edge, then in the int icon i could poll the position of the switches and use decisions to do the same thing, so when ever i would press a switch it would activate external interrupt on edge which would give me a harware port interrupt as long as the 800mv drop of the diodes does not keep me from getting a logic one on B0, ...but this is not my perfered method but should work the same

Re: 16f1939/16f1938 missing port interrupts

Posted: Mon Nov 28, 2011 8:28 am
by medelec35
brandonb wrote: 800mv drop of the diodes does not keep me from getting a logic one on B0
I would say 800mV is at the very top edge of logic 0. With low forward current involved the voltage drop of the diode should be a bit less than 0.8V.
If you want to play it save you could consider a Schottky diode instead?
at about 1mA the forward voltage drop should be less than 0.4V
These type of diodes are use to prevent transistors from saturating, and for clamping Voltages as near to supply voltage as possible.

Martin

Re: 16f1939/16f1938 missing port interrupts

Posted: Mon Nov 28, 2011 8:39 am
by brandonb
thinking about it, i rigged up a circuit on the original pic flowbench with a 1n4004 diode to stop the injtectors, thats about the same thing as what i was talking about so im sure it will work until the problem is resolved, thanks martin, i didnt realize the logic 0 would be that high, you have me curious to do some testing to see what a 1 and 0 are in voltage and bytes

Re: 16f1939/16f1938 missing port interrupts

Posted: Mon Nov 28, 2011 6:47 pm
by Benj
Hello,

I will try and sort this out for you tomorrow morning. If you don't hear from me then something probably came up so keep posting on this topic to remind me. I think ioc on these devices was left out of v4 because they had advanced features such as separate registers for interrupt on rising edge and interrupt on falling edge for each ioc pin. These advanced ioc features are now fully supported in v5 simulation and code generation.

Re: 16f1939/16f1938 missing port interrupts

Posted: Tue Nov 29, 2011 1:48 am
by brandonb
thanks ben, sorry for bugging you again it sounds like your a busy guy, that would be great if you could get that working for me, i do plan on buying v5 but wont be till january 20th

Re: 16f1939/16f1938 missing port interrupts

Posted: Tue Nov 29, 2011 12:58 pm
by Benj
Hello,

Right here are the updated FCDs with the port interrupts.

If you open the FCD into a text editor and then scroll down to the bottom then you will see the masks for the positive edge (iocbp) and negative egde (iocbn).

At the moment the full port is set to interrupt on any rising or falling edge.

Code: Select all

EnableCode="iocbp=0xff;\niocbn=0xff;\nst_bit(intcon, IOCIE);\n"
Please note that the v4 simulation will ignore the mask values and only work with the upper nibble of PortB whereas the hardware should work correctly.

Re: 16f1939/16f1938 missing port interrupts

Posted: Wed Nov 30, 2011 1:26 am
by brandonb
thanks ben, thats the trick, i tried it on b1 only and all is good, will have to get some more breadboards to fully experiment, upcoming projects are looking good with the files you helped me with, :D