Page 1 of 1

Can anyone help regard programming a PIC16F18325

Posted: Mon Nov 05, 2018 6:07 pm
by davidkilshaw
I have a requirement to take 2 bytes of information (a number from 0 - 1023) over I2c and provide a PWM waveform with a mark to space ratio of the number received.

I have managed to get the PWM to work in hardware to provide a PWM that is variable from a fixed register within the PIC but cannot get the I2C to be able to communicate with the Micro in hardware.

I want to achieve this a working hardware that is written in flowcode 8 so it can be amended easily moving forward.

Can anyone help in writing this software in flowcode 8

Any further questions please ask

Regards

Dave Kilshaw

Re: Can anyone help regard programming a PIC16F18325

Posted: Wed Nov 07, 2018 12:06 pm
by Benj
Hi Dave,

Please can you post what you have so far so we can see what you have tried and suggest what you may need to do to get things working.

I take it you have looked at the examples here.
https://www.matrixtsl.com/wiki/index.ph ... 3e364f2eff

Re: Can anyone help regard programming a PIC16F18325

Posted: Thu Nov 08, 2018 10:50 am
by davidkilshaw
I have looked at the wiki you suggest and have taken the code.

To describe the software

On boot the micro needs to do 3 things

Set 2 ports 1 high and 1 low ( done and working)
read the state of a digital input to be high or low. (if high it sets the i2C address to be A and if low sets the I2C address to be B (done and working)

Once this is done it needs to read a 2 byte number (0 - 1023) from the I2C address set in part 3 of boot up (not working)

This number is then used to set the mark space ratio of the internal 10 bit PWM in the micro. (this has been done with a variable and works)

After this point the PWM will continue producing the mark space ratio received until another value is sent oer the I2C address.

At present each block of code is written separately and once the i2C functionality is sorted then i can bolt them all together.

I have attached the I2C slave read block of code i have written but failed to get working. The port setting and delays are purely to flash an LED at different speeds to show where the code is in execution nothing more than that.

Thanks for your help so far

Regards

Dave Kilshaw

Re: Can anyone help regard programming a PIC16F18325

Posted: Wed Nov 28, 2018 7:11 pm
by JFinlayson
I suppose you have this working now. I don't have this chip to test prog with. But included modified program based on what I have working.