Page 1 of 1

pic12F1840 incomplete fcd and wake from sleep problem

Posted: Tue Jun 19, 2012 1:33 pm
by ocaltek
Hi All

No longer a NOOB but no flowcode guru either. I have been having alot of problems with the timer0 interrupt properties. Also the portB interrupt icon has not got any properties available. I have downloaded a new fcd file from another post about timer1 on this chip which helped tmr1 but not the port enable. Any help would be greatly appreciated. I did modify the fcd file to change the portb option see before and after below (compiled with no errors) I tried setting the the individual pin bit (IOCAN register) by c code window with no effect.

Code: Select all

 //C Code
	//C Code:
	
	{

	st_bit(iocan,IOCAN1);
	}
FROM
[PORTB]
Name="PORT"
FlagReg=
FlagBit=
HandlerCode="#ifndef MX_INTHANDLER_intcon_RAIF\n#define MX_INTHANDLER_intcon_RAIF\nchar mxtmp;\nif (ts_bit(intcon, RAIF) && ts_bit(intcon, RAIE))\n{\n\t#ifdef USE_FLOWCODE_ICD\n\t\textern char ICD_Interrupt_Enable = 1;\n\t#endif\t\n\tFCM_%n();\n\tmxtmp=porta;\n\tcr_bit(intcon, RAIF);\n\t#ifdef USE_FLOWCODE_ICD\n\t\textern char ICD_Interrupt_Enable = 0;\n\t#endif\t\n}\n#else\n#warning "This interrupt has previously been enabled, so the macro <%n> may never get called."\n#endif\n"
UseExplicitHandlerCode=1
UseExplicitEnableCode=1
EnReg=
EnBit=
EnableCode="st_bit(intcon, RAIE);\n"
DisableCode="cr_bit(intcon, RAIE);\n"
OptCnt=0


TO
[PORTB]
Name="PORT"
FlagReg=
FlagBit=
HandlerCode="#ifndef MX_INTHANDLER_intcon_IOCIF\n#define MX_INTHANDLER_intcon_IOCIF\nchar mxtmp;\nif (ts_bit(intcon, IOCIF) && ts_bit(intcon, IOCIE))\n{\n\t#ifdef USE_FLOWCODE_ICD\n\t\textern char ICD_Interrupt_Enable = 1;\n\t#endif\t\n\tFCM_%n();\n\tmxtmp=porta;\n\tcr_bit(intcon, IOCIF);\n\t#ifdef USE_FLOWCODE_ICD\n\t\textern char ICD_Interrupt_Enable = 0;\n\t#endif\t\n}\n#else\n#warning "This interrupt has previously been enabled, so the macro <%n> may never get called."\n#endif\n"
UseExplicitHandlerCode=1
UseExplicitEnableCode=1
EnReg=
EnBit=
EnableCode="st_bit(intcon, IOCIE);\n"
DisableCode="cr_bit(intcon, IOCIE);\n"
OptCnt=0




Im using flowcode version v4.5.18.74 Thanks in advance.

Cheers

Christian

Re: pic12F1840 incomplete fcd and wake from sleep problem

Posted: Tue Jun 19, 2012 2:36 pm
by Benj
Hello Christian,

I have just checked and these issues have been resolved in v5.

Your port interrupt FCD code looks to be correct but is missing the masks.

If you want to be able to select the Port Interrupt pins in v4 then you will need to use a C code icon just before the interrupt enable icon to set the pin mask.

iocap=0x3F;
iocan=0x3F;

The first value controls interrupt trigger on rising edge and the second controls interrupt trigger on falling edge.

The 0x3F sets port pins 0 through to 5 as interrupt sources, 0x01 would allow pin 0 only.

Note that FC 4 will be unable to simulate the port interrupt. This has also been fixed in v5.

Re: pic12F1840 incomplete fcd and wake from sleep problem

Posted: Wed Jun 20, 2012 9:05 am
by ocaltek
Hi Ben

Thanks for the help. Your solution compiled fine but would not work on hardware. Going through the C and asm file showed no issues all addresses were correct and the op-codes were right just would not function didn't matter what pin was pulled low would not interrupt. I have made a compromise. To do something that looks like sleep with out sleep mode. I guess I will have to upgrade to V5. Its very odd as I have used the same type of functions in a 16f series processor with no problems what so ever. Thanks again.

Cheers

Christian