Jump to content

C for dummies, I need this book


yogi
 Share

Recommended Posts

So I got a question, and feel like it's a 'dumb' question, but what the hey, I spent the evening working it out and wanted some input.

 I'm messing with the 8x8 scan matrix for MIOS8, and am expanding it a bit for a little project. Was setting up variables for transposing note range and Midi out channel. 

At first tried adding to the display using 'pin' which is returned from the sm_ButtonHandler, but found it was out of scope in Display_tick(). So above Init() I added sm_button_pin and within SM_NotifyToggle() this:

       sm_button_pin=pin;

This works, with sm_button_pin being global. Then added vars for chan_out and note_offset

        unsigned char chan_out=0;

This seemed to work but when I tried to set it to 3 or what have you, no change. What I finally did was:

          unsigned char chan_out;

And in Init() added this:

           char_out=3;

 

So is there a better/cleaner way? I was thinking it should be in main.h rather then main.c but couldn't get it working; even tried to add sm-button-pin as an export from sm_simple.asm. My C skills are way behind compared to assembly, feeling bad it took so long just setting and using a variable! Are there any online refs for SDCC and C in general? Have a few dusty C++ books and a couple CCS C manuals, guess I'll have to clear of the cobwebs :)

Thanks,

Yogi

Link to comment
Share on other sites

It would work with a common C flow (e.g. on a MIOS32 core), but it doesn't work with MIOS8 in conjunction with the quick&dirty SDCC adaption, because it doesn't take care about variable preloading and initializes all variables (which are not declared as a const) with 0

 

So, you are on the right track, there is no cleaner way with the MIOS8/SDCC combo.

 

Best Regards, Thorsten.

Link to comment
Share on other sites

OK.thanks. The differences between standard C, CCS, MPLab C and SDCC in combination with my aging memory is a bad mix:)

Will have to spend some time with the SDCC docs, Thanks again for your efforts, even though MIOS8 is 'old school', it is such a great package to work with:)

yogi

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...