Search found 1160 matches

by mnfisher
Sat Dec 14, 2024 7:30 pm
Forum: Feature Requests
Topic: PWM + Сapture + Сomparison
Replies: 18
Views: 570

Re: PWM + Сapture + Сomparison

I modified to run with a PIC12F18440. Running at 32MHz and capturing every 16th rising edge it can measure 320kHz (or more) (giving a count of 380 at 320kHz) 1000006184.jpg Here measuring an 80kHz signal - which the scope shows as have 12.5us between rising edges - so 16 count is 200us. (1/80000 * 1...
by mnfisher
Sat Dec 14, 2024 2:02 pm
Forum: Feature Requests
Topic: PWM + Сapture + Сomparison
Replies: 18
Views: 570

Re: PWM + Сapture + Сomparison

The capture looks to time 1 (or 4 or 16) - interrupts. So although we have a delay - we are not timing all the pulses in 1 (or in my case 4) seconds - and the time elapsed would be the length of the delay (assuming timer 1 hasn't overflowed). We do, however, need a delay - otherwise the display will...
by mnfisher
Thu Dec 12, 2024 10:42 pm
Forum: Feature Requests
Topic: PWM + Сapture + Сomparison
Replies: 18
Views: 570

Re: PWM + Сapture + Сomparison

The display should show number of 'ticks' of TMR1 between measured interrupts - so this can be set to every rising / every 4th or every 16th for example. The 'actual' time depends on the clock frequency - which will vary depending on FOSC. The results I get are very consistent. It is worth disabling...
by mnfisher
Thu Dec 12, 2024 2:29 pm
Forum: Feature Requests
Topic: PWM + Сapture + Сomparison
Replies: 18
Views: 570

Re: PWM + Сapture + Сomparison

Looks like you just want to toggle bit 0

CCP1CONbits.NAME = ~CCP1CONbits.NAME

Where name is the name of the bit field should do this...

Martin
by mnfisher
Wed Dec 11, 2024 8:17 am
Forum: Feature Requests
Topic: PWM + Сapture + Сomparison
Replies: 18
Views: 570

Re: PWM + Сapture + Сomparison

A bit more playing... Setting capture to every 16th rising edge (CCP1CONbits.CCP1M = 0b0111; ) - and it is happily measuring pulses at 40kHz. Not bad for a 8Mhz MCU. It seems to be the max internal clock - can be externally clocked faster. - As it stands - clock is set as 32MHz but the 1s delay is r...
by mnfisher
Tue Dec 10, 2024 11:05 pm
Forum: General
Topic: Best tactic to decode JSON data..
Replies: 17
Views: 1469

Re: Best tactic to decode JSON data..

We got there in the end.... Easily done - see my post this evening about trying to fit 16 bits of data into a byte :-( Sometimes it just needs a different pair of eyes. You could have a macro PrintFloat - that takes a float x (and possibly number of digits after dp) and a position - convert x to a s...
by mnfisher
Tue Dec 10, 2024 10:28 pm
Forum: Feature Requests
Topic: PWM + Сapture + Сomparison
Replies: 18
Views: 570

Re: PWM + Сapture + Сomparison

Okay - a little tidying. A silly mistake - t is a byte in Capture not a 16 bit word as it should be :-( I also disable peripheral interrupts around the print - pulse is also set to 0 to 'prove' that the signal is read.. Now a 2kHz square wave gives 956 / 959, 1kHz gives 1957. 5kHz gives 333.... (Not...
by mnfisher
Tue Dec 10, 2024 5:33 pm
Forum: General
Topic: Best tactic to decode JSON data..
Replies: 17
Views: 1469

Re: Best tactic to decode JSON data..

It's a silly question/thought...

If you are using the ILI9488 PrintNumber to display the value then it will, indeed, get converted to am integer. PrintNumber takes an Int (so just 16 bits too) - and no digits after the point!

Martin
by mnfisher
Tue Dec 10, 2024 5:20 pm
Forum: Feature Requests
Topic: PWM + Сapture + Сomparison
Replies: 18
Views: 570

Re: PWM + Сapture + Сomparison

FCL_ (and the '.' in .t) - correspond to a local variable in the macro. Pulse is a global (FCV_ in C code). Note that I could have assigned directly to pulse - but I actually intended to change to a union and eliminate the shift / addition for extra speed. Time ran short - I need my beauty sleep. I'...
by mnfisher
Tue Dec 10, 2024 11:34 am
Forum: Feature Requests
Topic: PWM + Сapture + Сomparison
Replies: 18
Views: 570

Re: PWM + Сapture + Сomparison

I'm not sure it's quite right - the value changes (so the interrupt is called) and do bear 'some' relationship to the signal I put in... I'll try with a different PIC (with hardware i2c). Microchip have some good docs on use of capture and compare (see https://ww1.microchip.com/downloads/en/DeviceDo...