Note that using SetHPTimerAfterNow can (and will) cause timing drift, you may want to compensate for that somehow (by using that usec counter for example).Another note: using the HP timer with that high repetition rate may cause problems. I'd recommend you to use a much slower loop to check for a 'start' signal (longer pulse), and switch to the high resolution timer when that arrives. This is for the receiver end of course.
int master_send_bit(){ *((volatile int *) MASTER_OUTPUT_ADDRESS) = MASTER_OUTPUT_MAGIC_NUMBER_ON;//Set LED on if (master_message_buffer & (1 << master_bit_number)) //Check if the next bit is a 1 { _SetHPTimerAfterNow(MASTER_BIT_1_DELAY,master_send_space,master_send_space,0);//delay for 1 } else { _SetHPTimerAfterNow(MASTER_BIT_0_DELAY,master_send_space,master_send_space,0);//delay for 0 } master_bit_number++; //Should hopefully increase before master_send_space runs}int master_send_space(){ *((volatile int *) MASTER_OUTPUT_ADDRESS) = MASTER_OUTPUT_MAGIC_NUMBER_OFF;//Set LED off if(master_bit_number == 16) //data transmission has finished. { _SetHPTimerAfterNow(MASTER_END_DELAY,master_end_transmission,master_end_transmission,0); } else { _SetHPTimerAfterNow(MASTER_DELAY_SPACE,master_send_bit,master_send_bit,0); }}
Any ideas on how I could get around this?
https://www.google.com/search?q=c+function+prototypeSorry for the short answer, I have important things to do.
Is it possible to instead of setting the timer after now, to set it at a particular time (based on checking the usec counter).
another question, I have the bitwise operator master_message_buffer & (1 << master_bit_number) used to extract the bit I want to send, it would be correct to have master_bit_number set to 0 to read the first bit right?
It is possible, use SetHPTimerAfterTimeout.http://chdk.setepontos.com/index.php?topic=10114.msg109695#msg109695It's using *(int*)0xc0242014 as time base (reminder: this is a 20bit counter, prepare for wraparound).
int master_begin_transmission(){ *((volatile int *) MASTER_OUTPUT_ADDRESS) = MASTER_OUTPUT_MAGIC_NUMBER_ON;//Set LED on _SetHPTimerAfterTimeout(*(int*)0xc0242014,131072,master_begin_transmission_delay,master_begin_transmission_delay,0);// _SetHPTimerAfterNow(131072,master_begin_transmission_delay,master_begin_transmission_delay,0);}int master_begin_transmission_delay(){ *((volatile int *) MASTER_OUTPUT_ADDRESS) = MASTER_OUTPUT_MAGIC_NUMBER_OFF;//Set LED off _SetHPTimerAfterTimeout(*(int*)0xc0242014,131072,master_begin_transmission,master_begin_transmission,0);// _SetHPTimerAfterNow(131072,master_begin_transmission,master_begin_transmission,0);}
and would it likely interfere with othe canon processes?
my only question would be how fast would the continuous loop be
int master_begin_transmission(){ while (variable_to_increment < 67108864) { variable_to_increment++;// unread_variable = *(short*)0xc090004a;// unread_variable1 = *(int*)0xc0242014; } *((volatile int *) MASTER_OUTPUT_ADDRESS) = MASTER_OUTPUT_MAGIC_NUMBER_ON;//Set LED on}
When polling the temp input, it was of course slower, at about 6 million per second, which is still more than fast enough. And about 4 million per second with reading the usec timer aswell.
Thanks, however it seems to behave just like SetHPTimerAfterNow for some reason._SetHPTimerAfterTimeout(*(int*)0xc0242014,131072,master_begin_transmission,master_begin_transmission,0);I would have expected the above to run when *(int*)0xc0242014 is equal to 131072, but it instead runs after 1/8 of a second, as SetHPTimerAfterNow would.
Started by fudgey General Discussion and Assistance
Started by srsa_4c « 1 2 » General Discussion and Assistance
Started by lipefrs « 1 2 » Script Writing
Started by reyalp DryOS Development
Started by reyalp General Discussion and Assistance