Fcy is always half of the oscillator frequency. Thus I'm setting the
oscillator to 32MHz to achieve the maximum clock rate of 16MHz.
Reducing it is non-trivial: certain parts of the code assume a 16MHz clock
and would otherwise break. If all you need is a small number of features,
you might be able to get away with a small number of changes. There's also
a risk that the PIC will not be able to keep up if you clock it too slow.
If we take a step back for a second, what is this mysterious device that
expects such an uncommon I2C clock rate? Would it be feasible to simply
replace it with something more standard? Otherwise, are you willing to
consider a small MCU in between the IOIO and the device that mediates the
clock rates?


On Fri, Mar 14, 2014 at 11:31 AM, Rich <[email protected]> wrote:

>
> Awesome, great find! Thanks!
>
> I assumed it was 16 bits, but now when I looked back at the document (not
> straight forward since the I2CXBRG register data is in another section and
> XC16 I2C examples are hard to find through Microchip) I found the register
> table and it is indeed a 9-bit register limiting me to 31KHz (0x1FF) I2C
> clock. I re-verified my I2C clock outputs for 0x1FF and I get about 28 KHz
> and retried 0x63D or 0x03D and got about 242 KHz (original Oscilloscope
> measurement was off, due to the way I scaled it). All checks-out.
>
> With Fcy set to 16MHz, are you using an internal clock rate at 32MHz? I
> assume this not worth changing to accommodate my speed requirements. Maybe
> I'll look into using a serial to I2C interface.
>
>
>
> On Thursday, March 13, 2014 9:22:52 PM UTC-7, Ytai wrote:
>
>> Aha! The BRG register is 9-bits, so your 0x63D became 0x3D => 250KHz (not
>> sure why you got 100KHz). So apparently you cannot go so low @ 16MHz. The
>> lowest setting would be 0x1FF => 31KHz.
>>
>> Not sure why BT got messed up for you. Does it work with the stock v5.00
>> firmware for you? If so, something must be problematic with the build. I
>> don't regularly build with XC16.
>> As a side note, you probably want to use IOIOLib v5.03 and IOIODude v1.01
>> for a happier life (many little bug fixes in addition to the new features).
>>
>>
>> On Thu, Mar 13, 2014 at 4:40 PM, Rich <[email protected]> wrote:
>>
>>>  . . . I'm quite sure I'm running the Firmware I compiled. In one build
>>> I verified that I can generate 1MHz signal using the Rate_1MHz setting (BRG
>>> values{ 0x063D, 0x25, 0x0D }). I then I updated the firmware for the 3rd
>>> BRG element ({ 0x063D, 0x25, 0x063D }) and received about 100KHz when
>>> setting Rate to Rate_1MHz again.
>>>
>>> I first compiled everything in the firmware using MPLAB X and XC16.
>>> Secondly, I used "tools/make-ioio-bundle firmware/app_layer_v1/dist/
>>> I2C_FirmWare.ioioapp IOIO0030" to create the bundle to download.
>>> And finally I used "../IOIODude-0100/ioiodude --port=/dev/ttyACM0
>>> --reset write I2C_FirmWare.ioioapp" to download the firmware to the IOIO
>>> board. This wrote to the device since there was Fingerprint mismatch.
>>>
>>> The Firmware I used was pulled from ioio-master. I modified the IOIO
>>> Simple APP under IOIO400 to test the changes. I added the twi commands to
>>> the button switch of which I could see output on the I2C lines with my
>>> oscilloscope and verify the clock rates.
>>>
>>> I also noticed that my bluetooth dongle no longer flashed on, so I had
>>> to wire directly to my cellphone.
>>>
>>>
>>>
>>> On Thursday, March 13, 2014 1:26:40 PM UTC-7, Rich wrote:
>>>>
>>>> May have replied directly with my reply and didn't post properly . . .
>>>> please re-post question here if you got it, else I'll put it back up.
>>>> Thanks.
>>>>
>>>> On Thursday, March 13, 2014 8:43:39 AM UTC-7, Ytai wrote:
>>>>>
>>>>> This seems the right place to change. Are you sure you are actually
>>>>> running the firmware that you've modified? How did you install it on the
>>>>> IOIO?
>>>>>
>>>>>
>>>>> On Wed, Mar 12, 2014 at 8:06 PM, Rich <[email protected]> wrote:
>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> I was wondering, has anyone (users and/or the IOIO inventor)
>>>>>> experimented with modifying the I2C clock rates below and beyond the
>>>>>> currently supported rates (100KHz, 400kHz, 1MHz)?
>>>>>>
>>>>>> I have a device that can only run at 10KHz . . . I updated line 129
>>>>>> in the i2c.c IOIO firmware source (static const unsigned int 
>>>>>> brg_values[] =
>>>>>> { 0x063D, 0x25, 0x0D }; //first element updated from 0x9D for 10KHz),
>>>>>> compiled and downloaded the firmware. Using the correct enum RATE value, 
>>>>>> I
>>>>>> received about 100KHz on my oscilloscope showing the incorrect clock rate
>>>>>> not the new 10KHz. I also built another firmware version updating all of
>>>>>> the brg_values to 0x063D to ensure that the changes were being passed
>>>>>> properly and I confirmed that when I set the TWI rate to 1MHz for 
>>>>>> instance,
>>>>>> I also receive 100KHz.
>>>>>>
>>>>>> Does the internal clock runs at 32 MHz? Any possible issues with
>>>>>> modifying these values? I don't see anything in the PIC24 datasheet 
>>>>>> showing
>>>>>> that I am limited to these three clock rates. Can anyone confirm?
>>>>>>
>>>>>>
>>>>>> Thanks for your help and assistance.
>>>>>>
>>>>>> Best,
>>>>>> Rich
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "ioio-users" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>> send an email to [email protected].
>>>>>> To post to this group, send email to [email protected].
>>>>>> Visit this group at http://groups.google.com/group/ioio-users.
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "ioio-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at http://groups.google.com/group/ioio-users.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "ioio-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/ioio-users.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to