HI
I did not check that the device really runs at the correct frequency as I supposed you check that with a blinking led ( also do not have such an device guessing at the moment)
I modified what I think it should be for 10Khz on PWM1 with Timer 1,I load a fix value of around 50% Duty cycle in the PWM1 call(macro)
Just as a information on the dsPIC and PIC24 devices if your timer period is for example 400 cycle to achieve the Frequency you want then the duty cycle you have to set is 400 = 100% 200 = 50% and 25% = 100 and so on .if these things does not match then there is no PWM output (in general) try this PWM1 and let us see where we are standing
PIC24FJxxGB002 and GA002
- p.erasmus
- Valued Contributor
- Posts: 434
- http://meble-kuchenne.info.pl
- Joined: Thu Dec 03, 2020 12:01 pm
- Location: Russia / Россия
- Has thanked: 104 times
- Been thanked: 88 times
- p.erasmus
- Valued Contributor
- Posts: 434
- Joined: Thu Dec 03, 2020 12:01 pm
- Location: Russia / Россия
- Has thanked: 104 times
- Been thanked: 88 times
Re: PIC24FJxxGB002 and GA002
It just a zip file ,ok that sound good then I suppose Ben needs to look at the Remap pins
Regards Peter - QME Electronics
-
- Matrix Staff
- Posts: 1739
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 440 times
- Been thanked: 603 times
Re: PIC24FJxxGB002 and GA002
Hello,
I've had a good poke around in the datasheet and looked at the remap registers and values being passed by Flowcode and so far it all appears to be correct.
You said this.
If you create a simple program with a single PWM output which pins / timers are working. If you can somehow narow down the problem to a timer setting or pin setting then that might help.
If you look at the generated C code then you can see the PWM remap values being generated. Here is PWM channel 1.
These are the lines that handle the remapping.
Here are the output register bits, showing RP2R and RP3R inside register RPOR1.
And finally the RP pin assignment
Hopefully with a simple test we can get to the bottom of what's going wrong for you.
Could it be something simple like opens or shorts on your PCB? Can you confirm with a multimeter.
I've had a good poke around in the datasheet and looked at the remap registers and values being passed by Flowcode and so far it all appears to be correct.
You said this.
and then said this.found that I can get pin 7 to produce the PWM when I assign to that pin, but not the others.
The remap must be at least partially working as all outputs are by default set to null output.the PWM works perfectly when assigned to RB3. Assigning to RB7, RB8, or RB9 fails to produce a signal
If you create a simple program with a single PWM output which pins / timers are working. If you can somehow narow down the problem to a timer setting or pin setting then that might help.
If you look at the generated C code then you can see the PWM remap values being generated. Here is PWM channel 1.
Code: Select all
/*========================================================================*\
Use :cal_pwm
:Variable declarations
:Macro function declarations
\*========================================================================*/
#define MX_PWM_REF1
#define MX_PWM_PRESCALE1 (1)
#define MX_PWM_PIN_1 (3)
#define MX_PWM_TYPE_1 (0)
#define MX_PWM_PORT_1 PORTB
#define MX_PWM_TRIS_1 TRISB
#define MX_PWM_CHANNEL_1 (1)
/*=----------------------------------------------------------------------=*\
Use :cal_pwm
:Supplementary defines
\*=----------------------------------------------------------------------=*/
#define MX_PWM
#define MX_PWM_REMAPPABLE
#define MX_PWM_RPOR_1 RPOR1bits.RP3R
#define MX_PWM_RPOC_1 18
#define MX_PWM_OCxCON
#define MX_PWM_TMR_1 1
Here are the PWM channels#define MX_PWM_RPOR_1 RPOR1bits.RP3R
#define MX_PWM_RPOC_1 18
Here are the output register bits, showing RP2R and RP3R inside register RPOR1.
And finally the RP pin assignment
Hopefully with a simple test we can get to the bottom of what's going wrong for you.
Could it be something simple like opens or shorts on your PCB? Can you confirm with a multimeter.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Re: PIC24FJxxGB002 and GA002
Thanks Ben - In reading the data sheet - It discusses a requirement to write the remap code in assembly due to speed requirements. Is that something to consider?
I will take another look at the hardware and see if anything is wrong.
I will take another look at the hardware and see if anything is wrong.
Re: PIC24FJxxGB002 and GA002
I have the PWM channels working - I don't know why, but they are running. Some of my Analogs are not running. Could you take a quick look and see what I am doing wrong Ben?
The analog readings for AN9, 10 and 11 are reading zero - I have measured them on the pic, and they do have voltages.
The analog readings for AN9, 10 and 11 are reading zero - I have measured them on the pic, and they do have voltages.
- Attachments
-
- GB Program LED Driver.c
- (150.22 KiB) Downloaded 135 times
-
- Matrix Staff
- Posts: 1739
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 440 times
- Been thanked: 603 times
Re: PIC24FJxxGB002 and GA002
Hi Alan,
Sorry please can you post your .fcfx project file and I will investigate for you.
Sorry please can you post your .fcfx project file and I will investigate for you.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Re: PIC24FJxxGB002 and GA002
Thanks Ben
-
- Matrix Staff
- Posts: 1739
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 440 times
- Been thanked: 603 times
Re: PIC24FJxxGB002 and GA002
Thanks Alan,
Looking now...
Edit, I've found a problem with the ADC definitions for the GB002 / GB004 family and hopefully with the latest updates things should be working correctly for you.
Let me know how you get on.
Looking now...
Edit, I've found a problem with the ADC definitions for the GB002 / GB004 family and hopefully with the latest updates things should be working correctly for you.
Let me know how you get on.
I didn't see any problems with AN4 while looking through things so hopefully this one will work ok for you now too.The AN4 is not working but that is to be expected - According to the datasheet, it is not available. I will be trading pins on that one.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel