Search found 1469 matches

by Jerry Messina
Tue Dec 19, 2023 2:25 pm
Forum: User Modules
Topic: rs-485
Replies: 12
Views: 47620

Re: rs-485

There's the MicrocodeLoader (MCLoader) that comes with SF. If you use UMC mode you can create and build files for any configuration. It's a simple serial bootloader that resides in high-memory. Checkout https://www.sfcompiler.co.uk/wiki/pmwiki.php?n=SwordfishUser.UMCLoader You can access the help fi...
by Jerry Messina
Wed Dec 13, 2023 2:51 pm
Forum: User Modules
Topic: rs-485
Replies: 12
Views: 47620

Re: rs-485

The 28-pin parts are pin compatible, so you should have no hdw issues replacing a K22 with a Q43.

For whatever reason they haven't released any new parts with >= 64 pins in a while... I think the last one was the 18F6xK40, and that was before they added the hardware flow control feature.
by Jerry Messina
Tue Dec 12, 2023 11:10 pm
Forum: User Modules
Topic: rs-485
Replies: 12
Views: 47620

Re: rs-485

If you do switch, check out the 18F27Q43... it has a little bit of everything, along with 5 UARTS and 8K of RAM.
The only downside is the I2C peripheral. Since it doesn't have an MSSP you'd have to use one of the software I2C modules with it.
by Jerry Messina
Mon Dec 11, 2023 3:39 pm
Forum: User Modules
Topic: rs-485
Replies: 12
Views: 47620

Re: rs-485

I forgot to mention... if you're polling TRMT you may need an additional delay before disabling the TX.
TRMT gets set half way through the STOP bit, so if you don't have external failsafe biasing resistors the STOP bit will get cutoff too soon.
You need an additional 1/2 bit of delay time.
by Jerry Messina
Mon Dec 11, 2023 3:13 pm
Forum: User Modules
Topic: rs-485
Replies: 12
Views: 47620

Re: rs-485

Unfortunately, on most PIC18 devices the TRMT status bit must be polled... there's no interrupt associated with it. Some of the newer devices have hardware flow control (Q40/41, Q43, etc) that can do the job. If you don't have one of these then you have to do it manually... either wait some amount o...
by Jerry Messina
Thu Dec 07, 2023 3:08 pm
Forum: Modules
Topic: HPWM16 - 16bit hardware PWM module
Replies: 0
Views: 15352

HPWM16 - 16bit hardware PWM module

Here's a preview of the 16-bit hardware PWM module for devices with a PWM module (Q family). These devices have multiple PWM modules with up to 2 outputs each, so a single HPWM16.bas instance can provide up to 8 PWM outputs depending on the device and configuration. main_ex1.bas // HPWM16 example de...
by Jerry Messina
Fri Nov 17, 2023 12:37 pm
Forum: Modules
Topic: HPWM/HPWM2/HPWM3 hardware PWM modules
Replies: 16
Views: 80861

Re: HPWM/HPWM2/HPWM3 hardware PWM modules

I just thought i would report it in case anyone else has this problem. And thanks for that! I hadn't noticed the two register writes so I've modified the files to account for it. The registers are double-buffered, but I think one of the issues is that it can take several cycles to perform the duty ...
by Jerry Messina
Wed Nov 15, 2023 4:08 pm
Forum: Modules
Topic: HPWM/HPWM2/HPWM3 hardware PWM modules
Replies: 16
Views: 80861

Re: HPWM/HPWM2/HPWM3 hardware PWM modules

ok, so I've looked at a number of different methods for updating the duty cycle registers, and the worst is definitely the algorithm that's in the current HPWM.bas module where it ends up writing to CCPRxL twice. That's a pretty straight-forward thing to fix. But, that's not the whole story. The 10-...
by Jerry Messina
Wed Nov 15, 2023 12:32 am
Forum: Modules
Topic: HPWM/HPWM2/HPWM3 hardware PWM modules
Replies: 16
Views: 80861

Re: HPWM/HPWM2/HPWM3 hardware PWM modules

So, it seems that it may not be the sequence so much as the timing of when you can update the registers in order to get glitchless operation. I'll look at it a little closer tomorrow.
by Jerry Messina
Tue Nov 14, 2023 2:43 pm
Forum: Modules
Topic: HPWM/HPWM2/HPWM3 hardware PWM modules
Replies: 16
Views: 80861

Re: HPWM/HPWM2/HPWM3 hardware PWM modules

Seems like an easy way to fix this is to add a cast to the shift... Public Sub SetDuty1(pDuty As Word) CCPxCON.bits(5) = pDuty.1 // 2 lsb's go to DCxB[1:0] CCPxCON.bits(4) = pDuty.0 CCPRxL = byte(pDuty >> 2) // adding cast avoids two writes to CCPRxL End Sub Would you mind checking this out and see ...
by Jerry Messina
Tue Nov 14, 2023 2:03 pm
Forum: Modules
Topic: HPWM/HPWM2/HPWM3 hardware PWM modules
Replies: 16
Views: 80861

Re: HPWM/HPWM2/HPWM3 hardware PWM modules

That's interesting... I never noticed that. The difference is in how it codes the 'pDuty >> 2' statement. In the hpwm.bas SetDuty() routine (and your SetDuty1 routine) it has this: ?I000043_F000_000026_P000140 ; L#MK CCPRxL = pDuty >> 2 RRCF F0_U16H,0,0 MOVWF PRODL,0 RRCF F0_U16,0,0 MOVWF CCPR1L,0 <...
by Jerry Messina
Tue Oct 10, 2023 2:44 pm
Forum: Modules
Topic: HPWM/HPWM2/HPWM3 hardware PWM modules
Replies: 16
Views: 80861

Re: HPWM/HPWM2/HPWM3 hardware PWM modules

Seems this is my screw up in generating the device files. For the 14-pin 18F0xQ40 and 18F0xQ41, you should change the device files. Find the line '#const _ports' and add '#const _no_portb'... #const _ports = 2 // 2 available ports #const _no_portb = 1 // no PORTB That should fix it. Changes apply to...
by Jerry Messina
Tue Oct 10, 2023 1:05 pm
Forum: Modules
Topic: HPWM/HPWM2/HPWM3 hardware PWM modules
Replies: 16
Views: 80861

Re: HPWM/HPWM2/HPWM3 hardware PWM modules

There seems to be an issue with the 14-pin versions of the Q40/Q41 and the 'IsValidPort()' check Those parts have no PORTB (just PORTA and PORTC), and that's causing the failure. HPWM.bas works ok with the 20-pin version 18F16Q41... it has ports A, B, and C For the time being you can comment out the...
by Jerry Messina
Fri Oct 06, 2023 1:56 pm
Forum: Compiler
Topic: finding the first bit set to '1'
Replies: 0
Views: 15257

finding the first bit set to '1'

I ran across this code and thought it was a neat trick, so I adapted it to SF. It locates the first bit in a byte that's set to a '1' // // find lowest bit set in a byte // returns bitmask indicating the first set bit, or 0 if none are set // function FindLowestBit(b as byte) as byte // this functio...
by Jerry Messina
Sun Oct 01, 2023 3:01 pm
Forum: Modules
Topic: Suart module with parity bit
Replies: 12
Views: 10550

Re: Suart module with parity bit

Try this version of suart_parity.bas (it should clear up the "EWWO" issue) I changed the attributes of the parity functions to use 'access', which appears to be required since they're called from functions with that attribute. Without that it was overlaying variables. I wasn't aware of that since 'a...