Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:07 06 Jul 2025 Privacy Policy
Jump to

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 : Modification to SuperClock.bas

Author Message
Trakky
Newbie

Joined: 12/07/2014
Location: Australia
Posts: 9
Posted: 11:42pm 17 Oct 2016
Copy link to clipboard 
Print this post


This post carries on from my first post, “Micromite Based SUPER CLOCK” on 28 Aug 2016.

In my original design I included a DDM4 LCD display to display time (HH:MM format), this was fitted adjacent to our bedhead, it worked well and my wife was pleased with it.

To utilise the Super Clock I would have add an interface to it, the interface is simple, 5V level data, clock and load lines, clock out 32 bits of data and when finished pulse the load line to latch it into the DDM4.

I added some code to the SuperClock .bas program, this appeared to be looking OK at the output when checking with my oscilloscope but decided to do replace the MMBasic codewith a Cfunction, that’s when my problems started. This would also give me some experience writing and adding a Cfunction to a MMBasic program.

I followed Peter Mather’s 1st article, Cfunctions - learning by example, set my computer up as described (MBLAB-X, C Compiler), everything appeared to be OK after a few of my mistakes were corrected, used CFGen V1.0, copied the output into the end of Super Clock .bas and ran it only to be rewarded with continuous resets and “Couldn’t find TxToDDM4 function” messages. So back to the books, made several changes with the same results.

I read more of Peter’s later “CFunctions - learning by example” posts and discovered that the C “switch” statements didn’t work so changed them to “if else” statements, but alas, no change in the outcome.

At first, the output from CFGen only produced the code for the 3 functions that I had written (TxToDDM4Small), but after uninstalling and re-installing MPLAB-X and the C Compiler (Ver 3.10 & Ver 1.33 respectively) plus setting up Optimization and Additional options, re-compiling, the CFGEN output was my 3 functions plus a large piece of code (TxToDDM4Large) above the 3 functions.

So now, after getting frustrated with my non success and then in the last week breaking my leg I’ve decided to ask for help from The Back Shed. I’ll try to attach my latest C source file, the part of SuperClock.bas which I’ve renamed SuperClockDDM4.bas which I've made changes in in anticipation of getting my function to run and the two output files from CFGen plus the specs for the DDM4. i was not too sure where to initialise the ports for the three O/P lines, in the MMBasic code or C code, I finally decided to add it to the MMBasic, but haven't commented it out in the C Code (which is rather basic).

I've not written the correct values into the C code for the timing and pulse widths for the Clock and Load pulses, I was going to look at these with my scope after I got the MMBasic program running.

Thanks, hoping for some help to save my sanity,

Ken



2016-10-18_091739_VTTDDDM4.zip 2016-10-18_091938_TxToDDM4Small.zip 2016-10-18_092102_TxToDDM4Large.zip 2016-10-18_092210_SuperClockDDM4.zip 2016-10-18_092748_Lascar_DDM4.pdf





 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10209
Posted: 12:17am 18 Oct 2016
Copy link to clipboard 
Print this post

Looking very quickly, the big issue is that you are calling one function from another. You can only do this by using CFGen in "MERGE" mode and in which case you must use the "main" function as the only entry point into the routines. Typically I then use the first parameter to indicate which function is needed and the others are then passed to the required target functions.

Also do have a look at tutorial 4 which includes additional compiler and linker options that solve the switch issue and allow things like string literals to be used which makes debugging "print" statements much easier.
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025