AdamParlane / aut-swarm-robotics

AUT 2017 BE (hons/tech) final year project
2 stars 3 forks source link

Delay Function for TWI Bitbang #74

Closed EsMather closed 7 years ago

EsMather commented 7 years ago

Hey I've been writing some bit bang code for the camera. But it keeps locking up in the delay function. I was wondering if the delay function requires comms with the IMU? and is there a simple way for me to get the delay in 'uS' instead of mS?

wittsend commented 7 years ago

The short answer is no. The delay function uses timer0 which is initialised with the IMU at the moment. The problem is, that timer0 is used for the clock signal to the camera, so it won't work with the delay function. (Camera clock is 12MHz whereas I had timer0 running at 1kHz). If you are already using timer0 for the cameras 12MHz clock, then you just need to add code that increments systemTimestamp once every ms. You could try to make another counter that increments once every us, but I imagine it will overflow very quickly.

On 5/08/2017 10:37 AM, "EsMather" notifications@github.com wrote:

Hey I've been writing some bit bang code for the camera. But it keeps locking up in the delay function. I was wondering if the delay function requires comms with the IMU? and is there a simple way for me to get the delay in 'uS' instead of mS?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/AdamParlane/aut-swarm-robotics/issues/74, or mute the thread https://github.com/notifications/unsubscribe-auth/AKLNwCSQ2r6C_OpdLpCeRB0cdF1AJxkzks5sU50ygaJpZM4OuQbs .

AdamParlane commented 7 years ago

Just checking: this means that I need to change my use of it now too because system time stamp is incremented every 83ns instead of every 1ms?

wittsend commented 7 years ago

System timestamp needs to increment every 1ms because it is used by delay_ms and get_ms which are both needed for the IMUs DMP driver. So I guess you would need to rewrite the interrupt for timer 0 so that system timestamp still incremented every one msec and then add a new counter that incremented every 1us for bit banging.

On 6/08/2017 8:45 AM, "Adam Parlane" notifications@github.com wrote:

Just checking: this means that I need to change my use of it now too because system time stamp is incremented every 83ns instead of every 1ms?

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/AdamParlane/aut-swarm-robotics/issues/74#issuecomment-320469448, or mute the thread https://github.com/notifications/unsubscribe-auth/AKLNwDOv07_qHo5lyExKs_Ck0PIJaCOiks5sVNR6gaJpZM4OuQbs .

AdamParlane commented 7 years ago

Resolved with Merge #80, timer is now its own module. Interrupt now handles us and ms. Delay_ms and get_ms are untouched and intact. Camera frequency is still as is at 12.5MHz and delay_us is available to bit bang.