robinfawell
-
Posts
292 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Gallery
Posts posted by robinfawell
-
-
I have altered the delay to 750mS and even tried 1 second but my observations are the same. Occasionally I see the acknowledgement but mainly not.
I am not sure whether this is important or not. But it would promote confidence that the EEProm was being loaded.
Regards Robin
-
I have just started using MIOS STUDIO for uploads.
When using the tool to upload to Banksticks in the manual mode I've noticed that sometime I see the "received acknowledgement response" and most times not.
Is the lack of the message of any concern? Should it be there after every block?
I have some problem with my system and it is possible that the Banksicks may be involved.
Thanks Robin
-
Hi Thorsten
Thanks for the tip.
I have incorporated the line in my case statement 2 the following.
case (2) ://Read EEprom dependent on Memory pin selected. Set Memory Led in Radio Button Mode. For each stored group change to EEprom value. //Trigger SetLed_No Dump or SetLed_SendDump as appropriate. Read section of EEprom dependent on Memory Buttom pressed.
{
r =(pin-1<< 5) + 10;// determines the memory location which is dependent on Memory pin.
DIN_NotifyToggle((MIOS_EEPROM_Read ®), 0);//1st location, pedal group
DIN_NotifyToggle((MIOS_EEPROM_Read ®), 1); //this was a trial to see if it was necessary to release pin ... made no difference
DIN_NotifyToggle((MIOS_EEPROM_Read (r+1)), 0);//2nd location causes system resets in Midi_ox.
SendNote(0xB0, 0x02,MIOS_EEPROM_Read(r+1));//test
//SendNote(0xB0, 0x03,0x24); test
//////following is the code to set Memory group Led's when Record button not pressed.
//stored_pin = memory_group_stored_pin;// change value of stored pin to the memory group stored value
//stored_pin = SetLed_NoDump(1, 5, 9, stored_pin, pin, pin_value); //function, set pin_low to 0, pin_high to 5, canc_pin to 9
//memory_group_stored_pin = stored_pin;//resets the variable for this group to the current stored pin after the function above.
}
break;
On it's own the first Din_Toggle works to a large extent. However this is only the pedal group and I need to send a total of 12 similar Din_Toggles. When the second Din_Toggle is added the system generates repeated System resets.
I am conscious that the sending of sysex messages is quite long (in my case) and that there needs to be more control. In other words I do not know what I'm doing!
Please give me another pointer.
Regards Robin
Since sending this query I wonder whether there is a basic problem in calling a function from within the same function. This is what I am attempting.
-
It would help me to complete the Memorised setup if I could manipulate the pin and pin_value variables.
The pin (Din) values are stored and one way to complete the design would be to effectively alter the Din values in a simulated momentary action manner.
ie from a 1, momentarily to a 0, the back to a 1. I suppose to realistically simulate my PB's a few 10's of mS of "press" would be correct but I think much smaller values would do.
Thanks in advance.
Robin
-
Thanks again to Fluke and Stryd_one.
I'm back from my travels.
By the way I wasn't using pointers ie no *. Maybe you can't define an array using variables without using pointers. I'm too new to this to be sure.
Perhaps Thorsten could comment.
I have solved the problem without using an array. It took a while to figure out.
Solution
I defined a global variable q as an unsigned char.
I have 5 Memory Buttons Din 1 to Din 5. I want to store the variables in different sections of the (Internal) EEprom depending on the Pin Number.
I have reserved the first 10 memory locations for another purpose. The formula below divides the Memory into 25 address blocks. (I will use the unused space for other stored values.)
Each variable is stored in the next location. I think that the solution lacks the elegance of an array but it works!
q =25*(pin-1) + 10;// or even better, but I need to check the results
q =(pin-1<< 5) + 10;//as per Wiki C tips, bit shifting, multiplies by 32 instead of 25 but I have the space.
MIOS_EEPROM_Write(q , pedal_group_stored_pin);
MIOS_EEPROM_Write(q + 1, tremelo_strength_button_state);
MIOS_EEPROM_Write(q + 2, swell_princ_group_stored_pin);
MIOS_EEPROM_Write(q + 3, swell_mixt_group_stored_pin);
MIOS_EEPROM_Write(q + 4, swell_reed_group_stored_pin);
MIOS_EEPROM_Write(q + 5, great_princ_group_stored_pin);
MIOS_EEPROM_Write(q + 6, great_mixt_group_stored_pin);
MIOS_EEPROM_Write(q + 7, great_reed_group_stored_pin);
MIOS_EEPROM_Write(q + 8, pedal_couplers_group_stored_pin);
MIOS_EEPROM_Write(q + 9, sub_oct_coupler_button_state);
MIOS_EEPROM_Write(q + 10, swell_tremelo_select_button_state);
MIOS_EEPROM_Write(q + 11, great_swell_coupler_button_state);
MIOS_EEPROM_Write(q + 12, great_tremelo_select_button_state);
I would welcome any comments.
Robin
-
I have spent several hours digging around the compiler warning with no result.
With Stryd One's prompting I came across this
http://sdcc.sourceforge.net/doc/sdccman.html/node112.html
Is this relevant to my problem? I'm not sure.
Robin
-
Thanks to Stryd One, Mess and Fluke.
I have tried the references from Stryd One but no luck so far. Perhaps the forum will prove successful.
I have checked again. My variables used with the code snippets are definitely unsigned char. Perhaps I should emphasise that with the change in code I do not get a Compiler error now, I get a Warning.
It might help if I could find out what "Initializer different levels of indirections" means". I have some idea what initialise means, but not "indirections".
Robin
-
I am still worried aout the compiler warning I referred to in this thread, namely
warning 18: Initializer different levels of indirections
Does this matter? What does it mean? I have tried using the web to get an explanation but have had not obtained anything useful.
Is there a reference where compiler errors and warnings can be explained?
I would be grateful for any comments.
Robin
-
Thanks. Yes all the variables are unsigned chars.
The compiler shows a syntax error on the 2nd line of your suggested code.
Robin
-
Mess
Thank you for your input. The sizeof operator is very handy!
I have changed my code to the following. My code is slightly different to your suggested code.
However I still get the compiler warning shown below.
Altered Code
unsigned char stored_pin[] =
{pedal_group_stored_pin,// this is line 605
tremelo_strength_button_state,// etc etc as before
void Memory_IO(unsigned int start_addr ) // __wparam
{
unsigned char m;
for( m =0; m = sizeof(stored_pin); m++)
MIOS_EEPROM_Write(start_addr + m, stored_pin[m]);
}
Compiler text
Compiling main.c
Processor: 18F452
main.c:605: warning 18: Initializer different levels of indirections
What does this mean? Does the code seem right?
Robin
-
Sorry for the long post.
I want to store 13 variables (later on 21) in EEPROM. These will be stored in different blocks of the 256 locations, dependent on the start address (There are 6 start addresses and there will be 6 different stored blocks.
Each of the 13 variables are in reality pin numbers(DIN). The pin numbers will vary. The function Memory_IO has been prototyped [code]
unsigned char stored_pin[13] = { pedal_group_stored_pin,// tremelo_strength_button_state,// swell_princ_group_stored_pin,// swell_mixt_group_stored_pin,// swell_reed_group_stored_pin,// great_princ_group_stored_pin,// great_mixt_group_stored_pin,// great_reed_group_stored_pin,// pedal_couplers_group_stored_pin,// sub_oct_coupler_button_state,// swell_tremelo_select_button_state,// great_swell_coupler_button_state,// great_tremelo_select_button_state }; void Memory_IO(unsigned int start_addr, unsigned int finish_addr) // __wparam { //unsigned char value; //value = stored_pin[13] ; for(addr = start_addr; addr <= finish_addr; addr++) MIOS_EEPROM_Write(addr, stored_pin[13]); }Compiler text
Microsoft Windows XP [Version 5.1.2600]
© Copyright 1985-2001 Microsoft Corp.
C:\C_Stops>make
Makefile generated.
Makefile.bat generated.
Assembling MIOS SDCC wrapper
==========================================================================
Compiling main.c
Processor: 18F452
main.c:628: warning 24: index 13 is outside of the array bounds (array size is 1
3)
main.c:604: warning 18: Initializer different levels of indirections
==========================================================================
Compiling pic18f452.c
Processor: 18F452
==========================================================================
Linking project
==========================================================================
Converting to project.syx
Block 003000-0033FF allocated - Checksum: 1A
Block 003400-0037FF allocated - Checksum: 30
Block 003800-003BFF allocated - Checksum: 07
Block 003C00-003FFF allocated - Checksum: 73
Block 004000-0043FF allocated - Checksum: 43
Block 004400-0047FF allocated - Checksum: 2B
==========================================================================
SUCCESS!
C:\C_Stops>
This only works if I put 13 in the [] for the array. Even so I get the compiler warnings.
Can anyone see whether I am on the right track and make any comments. Thanks in advance.
Robin
-
Michael
I reset the Midi-ox buffer values to the recommended ones. Now I have no Midi-ox lock outs.
I haven't solved the problem but I have a strong suspicion that I am committing a bracket error or some other logical fault.
Robin
-
Michael
I think that there might be a problem with Midi_ox. I have tried a larger number of buffers eg 400 and it does not seem to lock out. I need further work tomorrow. I need to think about this some more.
Robin
-
Michael
There is no compiler error.
There is no hardware error until two buttons are pressed. Another button then pin 6, then Midi-ox locks out. If I switch applications to something else then when I switch back to Midi_ox then a stream of system resets appear on the Midi-ox input monitor.
I know that the hadware is OK from other tests. I have a test program that tests all the switches and Leds. Also an earlier version of my program execises the same pins and switches it is fine.
I am not claiming that my current software is OK, by the way.
I have not used MIOS Studio yet. Would it help in this case do you think?
What sort of software error could cause a problem like this. Might the problem be with Midi_ox?
Robin
-
Michael
I have tried your suggestion and it behaves the same. I should emphasise that the code compiles OK; the system reset appears afte the relvant switches are pressed.
Robin
-
Hello Michael
Answer to last question:
The MIOS_DOUT_PinGet is working properly in other parts of the code.
I will try your suggestions.
Regards Robin
-
I am finding that Midi-ox is locking up and sending a stream of system resets.
This problem started when I introduced (MIOS_DOUT_PinGet(6) ==0)) into the following conditional logic statements.
if (pin_value == 0)// only react when switch is pressed
if (pin >= 1 && pin <= 5) group = 1;
if(pin == 6) group = 2;
if ((pin >= 19 && pin <= 25) && (MIOS_DOUT_PinGet(6) ==0)) group = 3;
if (pin == 28) group = 4;
Can anyone suggest what the reason might be.
Thanks
Robin
-
I moved on to other aspects and received other errors due to new code. However I thought that I would see if you were right about brackets on the first if statement.
I commented out the new code that caused errors and compiled again. The was no warning 110. I then removed the brackets. Still no warning. I am bemused.
It's possible of course, that I have changed something else.
Thanks for your help again.
Robin
-
To Stryd One
Sorry about the mistake. I have corrected the original post. I copied case 1 instead of showing case 1 and case2.
Regards
Robin
-
I get a compiler warning referring to the "switch (group)" line below.
"main.c:262:warning 110: conditional flow changed by optomizer: so said EVELYN to the modified DOG"
Here is my code
unsigned char group;//used for switch statement
void DIN_NotifyToggle(unsigned char pin, unsigned char pin_value) __wparam
{
unsigned char stored_pin;
void DIN_NotifyToggle(unsigned char pin, unsigned char pin_value) __wparam
if (pin_value == 0){// only react when switch is pressed
if ((pin >= 1) && (pin <= 5))
group = 1;
if (pin == 7)
group = 2;
more code
switch (group)
{case (1) :{
{
stored_pin = memory_group_stored_pin;// change value of stored pin to the memory group stored value
stored_pin = SetLed_NoDump(1, 5, 9,stored_pin, pin, pin_value); //function, set pin_low to 0, pin_high to 5, canc_pin to 9
memory_group_stored_pin = stored_pin;//resets the variable for this group to the current stored pin after the function above.
}
break;
//////////Record (Used with Memory Group) ///////
case (2) :
{
stored_pin = record_button_state;// change value of stored pin to the memory group stored value
stored_pin = SetLed_NoDump( 6, 6, 7,stored_pin, pin, pin_value);//see case 1 with pins changed
record_button_state = stored_pin;//resets the variable for this group to the current stored pin after the function above.
}
break;
I have had these warnings before and have solved them usually by supplying missing brackets.
After a long seach on the web and can't find any useful reference to the statement.
Also there must be a list of errors and warnings listed somewhere.
Perhaps someone can point out the cause of the warning and point me to a source of error codes and warnings.
Thank you.
Robin
-
Thanks Michael
I have revised the code as you suggest. I agree that it is good practice to always use brackets. I have avoided them when there is only one statement following that is relevant.
As far as the logic is concerned I agree about the return statement. I suppose that I was lucky. In my case the results are the same. However the compiler, I think, will warn you if the return value is not sent
However I will indent the lines and insert brackets in future.
Thanks for your interest.
Robin
-
To MTE
I use line nimbering. You switch on or off, using view.
Right clicking on the line number provides a sub menu for bookmarking and a line goto.
Robin
-
Those who program in C and other languages might look at http://www.google.co.uk/search?client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial_s&hl=en&q=crimson+Editor&meta=&btnG=Google+Search
This is a free text editor with some good features.. It can show different items in colour.
You can configure it to provide a backup every time you save. It also has a lot of features that I have'nt used.
It is certainly one up on Notepad.
I have been using it for about 6 months.
Regards Robin
-
There are several reasons why I had difficulty.
I have in the past constructed simple functions where the use of a function can avoid repetition. One example is the sending of Midi messages.
The calling function could be
SendNote(0xb0, 0x7b, 0x00);// The midi message B0 7B 00 will be sent.
The related receiving function is
void SendNote(unsigned char chn, unsigned char note, unsigned int velocity) //__wparam
{
MIOS_MIDI_TxBufferPut(chn);
MIOS_MIDI_TxBufferPut(note);
MIOS_MIDI_TxBufferPut(velocity);
}
The above type passes values to the function but receives no parameters back.
Function where values are passed back to the calling function
Prototype
In my "difficult" case I needed to send back a value to the calling function. This involves a different prototype statement at the start of the program
#include "cmios.h"
#include "pic18f452.h"
void SendNote(unsigned char chn, unsigned char note, unsigned int velocity);
void SendTremelo();
void SendDump(unsigned char dump_index);
unsigned char SetLed_NoDump(unsigned char low_pin, unsigned char high_pin, unsigned char canc_pin, unsigned char stored_pin, unsigned char pin, unsigned char pin_value );
void RecordSetup ();
unsigned char dump_index; //triggers sysex messages
Note the 3rd, 4th and 5th lines. These refer to the functions where no values are returned.
Note the 6th line. This is the prototype statement where the function is preceded by the data type of the variable being returned. The function title follows.
Then the parameters or variables are listed (6 are shown).
Calling function
I have shown two cases out of about 12 . You will see the lines that include SetLedNoDump. These lines are the important ones; they send the values to the function.Note tha they are preceded by stored_pin. This is the variable that the function returns values to.
switch (group)
{case(1) :
{
stored_pin = memory_group_selected_stored_pin;// change value of stored pin to the group stored value (in this case the memory group.
stored_pin = SetLed_NoDump(0, 5, 9,stored_pin, pin, pin_value); // for the function, set pin_low to 0, pin_high to 5, canc_pin to 9
memory_group_selected_stored_pin = stored_pin;//resets the variable for this group to the current stored pin after the function above.
}
break;
//////////Record (Used with Memory Group) ///////
case (2) :
{
stored_pin = record_button_state;
stored_pin = SetLed_NoDump( 6, 6, 7,stored_pin, pin, pin_value);
record_button_state = stored_pin;
}
break;
Note that in Case 2, the variable to be manipulated is memory_group_selected_stored_pin.
Receiving Function
unsigned char SetLed_NoDump(unsigned char low_pin, unsigned char high_pin, unsigned char canc_pin, unsigned char stored_pin, unsigned char pin, unsigned char pin_value )
{
if (pin_value == 0)// only react when button is pressed.
if(stored_pin == pin) //Is the current pin the same number as the stored pin?
stored_pin = canc_pin;//If so, then alter the stored pin to the cancel pin allocated number for the group
else
stored_pin = pin; //otherwise make the stored pin vale, the current pin value.
for (i=low_pin; i<=high_pin; i++)// using i variable from 0 to 5
MIOS_DOUT_PinSet0(i);//set all pins in the group to "O"
if (stored_pin != canc_pin)//provided the stored value of the pin is not equal to the cancel number
MIOS_DOUT_PinSet1 (stored_pin);//set the current stored pin value to a "1"
return (stored_pin);
}
Note the Return statement.
This shows the logic associated with a group of momentary action push buttons with integral leds in a radio group. The rules are as follows.
Only one lamp may be on.
Pressing a button twice switches it off. Then all lamps will be off.
The causes of my troubles were:-
Ignorance of dealing with Functions requiring return values.
I also forgot to include the leading statement
if (pin_value == 0)// only react when button is pressed.
This is necessary when using momentary action switches.
That's all folks!
Robin
MBLAB Problem?
in MIOS programming (Assembler)
Posted
I have revised the files that I store in Bankstick. To keep the modules small, I plan to use 64K instead of 32K. This is really not relevant to the problem, just background.
I have a problem with the MBLAB compiler.
Using the same method that Thorsten suggested I find that although I list 39 include files in main.asm only 6 are compiled and "included" in the Main.lst file.
I have looked at the text carefully but cannot spot any errors.
There is one change. I am using version 7.5 of MBLAB IDE now. Could this be relevant?
Robin