Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : CFunction Not working
Author | Message | ||||
micronut Newbie Joined: 03/09/2014 Location: United StatesPosts: 37 |
I have this code Option Explicit CPU 48 LCDLightOn ' 'C:\CFunctions\BAS\lcdlighton.bas ' 'lcdlighton 2014-11-01 17:24:29 CFuncGen Ver 1.0.16 by user=Brian ' CFunction lcdlighton 00000000 3c02bf88 8c436114 34630001 ac436114 8c436138 34630001 ac436138 03e00008 00000000 End CFunction ' 'lcdlightoff 2014-11-01 17:24:29 CFuncGen Ver 1.0.16 by user=Brian ' CFunction lcdlightoff 00000000 3c02bf88 8c436114 34630001 ac436114 8c436134 34630001 ac436134 03e00008 00000000 End CFunction End And I get [4] LCDLightOn Error: Unknown Command Here is the C Code /* * File: LCDBackLight.c * Author: Brian * * Created on November 1, 2014, 2:21 PM */ #include <plib.h> #define BL_High *(volatile unsigned int *)0xbf886138 |= (1 << 0); #define BL_Low *(volatile unsigned int *)0xbf886134 |= (1 << 0); #define BL_Out *(volatile unsigned int *)0xbf886114 |= (1 << 0); /* * */ void lcdlighton(void){ BL_Out; BL_High; } void lcdlightoff(void){ BL_Out; BL_Low; } long long main() {} What am I doing wrong? |
||||
G8JCF Guru Joined: 15/05/2014 Location: United KingdomPosts: 676 |
You must assign the result of your CFunction to a 64 bit variable, eg Result%=lcdlighton Result%
Your CFunction MUST return a 64 bit integer, eg long long lcdlighton(){....} Peter The only Konstant is Change |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3167 |
Also, it needs a dummy argument otherwise MMBasic will think that it is a variable: Result% = lcdlighton(0) Geoff Graham - http://geoffg.net |
||||
G8JCF Guru Joined: 15/05/2014 Location: United KingdomPosts: 676 |
To follow on from Geoff's comments, the CFunction code could look like /* * File: LCDBackLight.c * Author: Brian * * Created on November 1, 2014, 2:21 PM */ #define BL_High *(volatile unsigned int *)0xbf886138 |= (1 << 0); #define BL_Low *(volatile unsigned int *)0xbf886134 |= (1 << 0); #define BL_Out *(volatile unsigned int *)0xbf886114 |= (1 << 0); unsigned long long lcdlighton(){ BL_Out; BL_High; return 0; } unsigned long long lcdlightoff(){ BL_Out; BL_Low; return 0; } void main() {} Then in MMBasic OPTION EXPLICIT CPU 48 DIM Result% Result%=LCDLightOn(0) END ' 'K:\Programming\PICProgramming\Micromite\UserSupport.X\dist\ default\production\lcdlighton.bas ' 'lcdlighton 2014-11-01 23:30:23 CFuncGen Ver 1.0.16 by user=Peter ' CFUNCTION lcdlighton 00000000 27bdfff8 afbe0004 03a0f021 3c02bf88 34426114 3c03bf88 34636114 8c630000 34630001 ac430000 3c02bf88 34426138 3c03bf88 34636138 8c630000 34630001 ac430000 00001021 00001821 03c0e821 8fbe0004 27bd0008 03e00008 00000000 END CFUNCTION ' 'lcdlightoff 2014-11-01 23:30:23 CFuncGen Ver 1.0.16 by user=Peter ' CFUNCTION lcdlightoff 00000000 27bdfff8 afbe0004 03a0f021 3c02bf88 34426114 3c03bf88 34636114 8c630000 34630001 ac430000 3c02bf88 34426134 3c03bf88 34636134 8c630000 34630001 ac430000 00001021 00001821 03c0e821 8fbe0004 27bd0008 03e00008 00000000 END CFUNCTION VERY IMPORTANT - NO SPACE allowed between LCDLightOn and (0), ie it MUST be LCDLightOn(0) @Geoff, is that fixable in 4.6 ? Give that a whirl, hopefully it will work ! Peter The only Konstant is Change |
||||
Print this page |