- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I use cy8y4124. based on a io I like to set clock for PWM module to 12MHz in one case and 1,2MHz in the other case. How to adchive this ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I recommend to have a variable indicating the current clock divider status not to generate a discontinuous clock..
uint8 clock_is_12MHz = 1;
for(;;) {
if (Pin_1_Read()) {
if (!clock_is_12MHz) {
Clock_1_SetDivider(2); // 24MHz/12MHz
clock_is_12MHz = 1;
}
} else {
if (clock_is_12MHz) {
Clock_1_SetDivider(20); // 24MHz/1.2MHz
clock_is_12MHz = 0;
}
}
// Other codes
}
Regards,
Noriaki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
RuGl,
Since your PSoC 4100 has no PLD resources, switching has to be done in code:
for(;;)
{
if (Pin_1_Read()) // set clock divider depending on pin status
{
clock_1_SetDivider(2); // 12 MHz
}
else
{
clock_1_SetDivider(20); // 1.2 MHz
}
CyDelay(1); //some delay
}
/odissey1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I recommend to have a variable indicating the current clock divider status not to generate a discontinuous clock..
uint8 clock_is_12MHz = 1;
for(;;) {
if (Pin_1_Read()) {
if (!clock_is_12MHz) {
Clock_1_SetDivider(2); // 24MHz/12MHz
clock_is_12MHz = 1;
}
} else {
if (clock_is_12MHz) {
Clock_1_SetDivider(20); // 24MHz/1.2MHz
clock_is_12MHz = 0;
}
}
// Other codes
}
Regards,
Noriaki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Noriaki,
thanks for the reply.
The method could be found in Clock_1.c. But there is no explanation inside code how to handle this divider. For there in no description of the peripherals at all and no possibility to have a look inside debugging It would be great to add some description in clock_1.h The header file just contains #define Clock_1_SetDivider(clkDivider) Clock_1_SetDividerRegister((clkDivider), 1u)but I had no chance to find clkDivider definition.
In the past I was used to have full view of peripherals , in user manual and debugger. Now, using cypress, I have no view to peripherals, and the functions that are generated automatically are not well described (eg. inside header file)
To add more function description is valid for all code generated automatically…
Best regards
Rupert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Rupert,
You can open a component datasheet document in PDF from the context menu as follows.
The datasheet contains the API function details.
Regards,
Noriaki