View previous topic :: View next topic |
Author |
Message |
dragonerd1
Joined: 22 Feb 2017 Posts: 1
|
PSMC configuration |
Posted: Wed Feb 22, 2017 1:03 pm |
|
|
I use PSMC for frequency variation. I use 32Mhz clock (8Mhx*4PLL).
Code: |
setup_psmc(1, PSMC_VARIABLE_FREQ, PSMC_EVENT_TIME | PSMC_SOURCE_FOSC | PSMC_DIV_8, us(usPeriodo), PSMC_EVENT_TIME, us(100), PSMC_EVENT_TIME, us(350));
|
In this line I configure PSMC_SOURCE_FOSC, I think it's 32Mhz. If I use PSMC_DIV_8, the frequency is 4Mhz. But the system still behaves as if it were configured at 32Mhz.
Why?
The code is not right? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Feb 22, 2017 2:59 pm |
|
|
dragonerd1 wrote: |
But the system still behaves as if it were configured at 32Mhz. |
And what is that behavior ? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19494
|
|
Posted: Wed Feb 22, 2017 3:36 pm |
|
|
and what chip/compiler version?. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9220 Location: Greensville,Ontario
|
|
Posted: Wed Feb 22, 2017 3:42 pm |
|
|
Also...does a 1Hz LED program run correctly ? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19494
|
|
Posted: Thu Feb 23, 2017 3:10 am |
|
|
You do realise that if you change the clock being used, you have to change the clock figure in the us define, to get it to do the calculations correctly?.
Code: |
#define us(time) (int16)(time*(getenv("CLOCK")/1000000))
|
This is assuming that the psmc is fed with the 'clock' (FOSC). To make these calculations work right if using FOSC/8, you have to change this define to match the clock being used. |
|
|
|