Application Development on the STM8S - Page 2 - Netduino Go - Netduino Forums
   
Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Application Development on the STM8S


  • Please log in to reply
28 replies to this topic

#21 mario

mario

    New Member

  • Members
  • Pip
  • 1 posts

Posted 29 November 2013 - 07:47 AM

Hi,

 

This is my first project with a ST mcu, I use a STM8S207K8, and the environment tool IAR. I use the internal oscillator, HSI at 16Mhz. One request is to output the CLK on an external pin. I noticed that pin PD0, has the CLK_CCO functionality, but I don't kow how to remap it.

Could you help me please?

 

Thank you in advcance.



#22 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 13 December 2013 - 06:48 AM

This is my first project with a ST mcu, I use a STM8S207K8, and the environment tool IAR. I use the internal oscillator, HSI at 16Mhz. One request is to output the CLK on an external pin. I noticed that pin PD0, has the CLK_CCO functionality, but I don't kow how to remap it.

Could you help me please?

 

In a recent project I used the following code to set the STM8S to do exactly what you are trying to do and I used the following code:

//--------------------------------------------------------------------------------////  Setup the system clock to run at 16MHz using the internal oscillator.//void InitialiseSystemClock(){    CLK_ICKR = 0;					   //  Reset the Internal Clock Register.    CLK_ICKR_HSIEN = 1;				 //  Enable the HSI.    CLK_ECKR = 0;					   //  Disable the external clock.    while (CLK_ICKR_HSIRDY == 0);	   //  Wait for the HSI to be ready for use.    CLK_CKDIVR = 0;					 //  Ensure the clocks are running at full speed.    CLK_PCKENR1 = 0xff;				 //  Enable all peripheral clocks.    CLK_PCKENR2 = 0xff;				 //  Ditto.    CLK_CCOR = 1;					   //  Turn on CCO.    CLK_HSITRIMR = 0;				   //  Turn off any HSIU trimming.    CLK_SWIMCCR = 0;				    //  Set SWIM to run at clock / 2.    CLK_SWR = 0xe1;					 //  Use HSI as the clock source.    CLK_SWCR = 0;					   //  Reset the clock switch control register.    CLK_SWCR_SWEN = 1;				  //  Enable switching.    while (CLK_SWCR_SWBSY != 0);	    //  Pause while the clock switch is busy.}

One thing you will have to check is the output of the CCO pin.  I found that I get a reasonable square-ish wave when operating a lower frequencies (i.e. 2 MHz) but when you get to 16 MHz the output is not very good.  The clock signal oscilates between about 1.5 and 3V at 16 MHz..  I have found that by feeding the output through a logic gate (I used an AND gate with one input tied high) you can get a usable clock signal out of the CCO pin.

 

BTW, the only reason I used an AND gate was because I had some single AND gates in stock from a previous project.

 

Hope this helps,

Mark


To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#23 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 20 June 2014 - 03:11 PM

For those who are still following this series, I've added a new article to this series - Using Auto-Wakeup on the STM8S.

 

Regards,

Mark


To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#24 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 20 June 2014 - 03:22 PM

Thanks for continuing to add to your series, Mark.

We've referred to your articles alongside the official STM8S documentation when we've built STM8S code here...you have a lot of great info and experience in there!

Chris

#25 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 20 June 2014 - 04:44 PM

Thanks Chris, good to know that this code is proving useful.

 

Wish I could solve my main problem though, so many projects and not enough time.

 

Regards,

Mark


To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#26 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 21 June 2014 - 02:45 PM

And your code may fail so add a Watchdog.

 

Regards,

Mark


To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#27 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 05 August 2016 - 08:07 AM

Added links to a few more articles from last year.

 

Regards,

Mark


To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#28 Jack Chidley

Jack Chidley

    Advanced Member

  • Members
  • PipPipPip
  • 99 posts

Posted 04 June 2017 - 02:12 PM

Several years on and I still find these articles useful Mark. Thanks for keeping them up to date.

#29 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 04 June 2017 - 04:32 PM

Glad you still find the articles useful.  I think I only have one area to look at, CAN, I think I may encounter resistance if I try playing around with the car.

 

Regards,

Mark


To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.