RSS

Contact

[si-contact-form form=’1′]

85 Responses to “Contact”

  1. G. Himangi says:

    Hello Mr. Stevens,

    I am Himangi from LogicNP Software, the developer of CryptoLicensing For .Net. CryptoLicensing for .Net is a 100% .Net solution to add licensing, copy-protection and activation capabilities to your .Net, Windows Forms (WinForms) and WPF applications, components and controls and ASP.Net web sites. CryptoLicensing uses the latest military strength, state-of-the-art cryptographic technology to ensure that your software and intellectual property is protected. You can find more info at http://www.ssware.com/cryptolicensing/cryptolicensing_net.htm

    I recently came across your blog at http://blog.mark-stevens.co.uk and found the articles to be quite interesting and useful.

    I am emailing to request you to consider reviewing or mentioning about CryptoLicensing for your site. I feel that your readers will find a review/information about CryptoLicensing quite useful, at the same time a review from an influential writer such as yourself can help us increase awareness of the product.

    I can provide a licensed copy of CryptoLicensing to you so that you can access its full functionality and I will gladly help you during the review process. If you charge any fees for your time, please let me know.

    Thank you for your time. Looking forward to hearing from you.

    Regards
    G.Himangi
    LogicNP Software

  2. Hi,

    There are some great projects on your blog, it’s a really nice online resource.

    We’ve been developing an Arduino-based rapid prototyping board that’s designed to make prototyping sensor and Internet-of-Things type projects faster and easier. It has pretty much all you need on one board. It’s called SODAQ. It recently got a lot of attention at Maker Faire Rome including from Atmel and Seeed Studio (we use their Grove sockets). Naturally, now we’re about to start producing it we’re running a Kickstarter to get it going…

    We’re Oxford and Netherlands based, and trying to let as wide a variety as possible of developers and electronics hobbyists here know about it. Would be really grateful for any tips you might have on promoting it a bit.

    For further info, our website is http://www.sodaq.net

    The Kickstarter page is http://www.kickstarter.com/projects/386717175/sodaq-a-lego-like-plug-in-rapid-prototyping-board

    And our Github repository is https://github.com/SodaqMoja

    Best regards,

    James

  3. Farrukh Hussain says:

    Sir I started work on STM8S few days back, just found your wonderful blog but i’m not understanding these codes are from which compiler?

    thank you very much in advance

  4. Sidney Smith says:

    Please I have goon through your tutorials. I am using STM8S Discovery with Cosmic C compiler. I am having some difficulties to test your source codes.

    Please can you advice me on how to proceed.

    Kind regards

    Sidney Smith

  5. Hi Mark,

    First and foremost, thank you for posting the UART code snippets for STM8 – I’ve been tasked with debugging an ST-based board with absolutely no ST micro / IDE knowledge, your website has been an immense help.

    If I may just point out a tiny issue which may or may not be localised to a single page on your website (OCD mode *ON*): http://blog.mark-stevens.co.uk/2012/08/using-the-uart-on-the-stm8s-2/

    Line 12 of the third code block: UARTPrintF(“Hello from my microcontroller….nr”);

    It appears as though the backslashes are being stripped out of your posted content (clearly it was meant to be an escaped linefeed and carriage return)

    Petty, I know, but I figured I’d want someone to tell me about that if it happened on my own website, perhaps you’re the same

    Again, thank you, and keep up the fantastic work!

    • Mark says:

      Good to hear that the STM8S information is proving useful.

      Thanks for the information about the error on the page. I’ll get it corrected.

      Good luck with your projects.

      Regards,
      Mark

  6. Sharique Hussain says:

    provide me a simple example of flash EEPROM(Read/Write) through Registers in stm8s

  7. Sharique Hussain, Nadeem Siddiqui, Shakti Saini says:

    #include “stm8s105c6.h”

    #define PointerAttr @ near
    unsigned int Address = 0x0010A5;
    unsigned char Data = 20,Read = 0;

    main()
    {
    FLASH_CR1 &= (~0x01);
    FLASH_CR1 |= 0x00;

    if (FLASH_IAPSR == 0x00) // DUL Bit 0 for Enable
    {
    FLASH_DUKR = 0xae;
    FLASH_DUKR = 0x56;
    }

    while(1)
    {
    (*( PointerAttr*)Address) = Data;
    delay(1000)
    Read = (*( PointerAttr*)Address);
    }
    }

  8. Sharique Hussain, Nadeem Siddiqui, Shakti Saini says:

    This program write/read properly

  9. Mehwish Mushtaq says:

    Hello Mr. Stevens

    i want to use multiple channels of ADC through registers in stm8l just as five or six channels . So guide me the right way.

    i write as ADC_CR3 = 0x07|0x0B|0x16|0x17|0x0E
    it just a example is it right?

  10. Drexel Haden says:

    Thanks so much for the great site. I have a bit of a newb question regarding timers on the STM8. Is it possible to configure a timer to cause an update interrupt every 30 seconds? I can only get this working down to 1ms. I don’t require any PWM output, just a 30 second wait before triggering an interrupt.

    • Mark says:

      I do not know the answer to this by but this is what I would look at if I was investigating this problem:

      1 – Use a higher speed interrupt and count how many time this happens until I have reached 30s, reset the counter and execute the action.
      2 – Check to see if you can feed the low speed oscillator to any of the the timers.

      I’m glad you find this site useful.

      Hope this help,
      Mark

  11. Justus says:

    I want to use interrupts on STM8L Discovery Board.
    Id found your Code for useing interrupts on the STM8S MCU.
    They are similiar but i get stuck while translating this follwing section for the STM8L.
    // Set up the interrupt.

    26.EXTI_CR1_PDIS = 1; // Interrupt on rising edge.
    27.EXTI_CR2_TLIS = 1; // Rising edge only.

    PDIS and TLIS does not exist.Id only found this.
    In iostm8l152c6.h //

    #define EXTI_CR1_P0IS EXTI_CR1_bit.P0IS
    #define EXTI_CR1_P1IS EXTI_CR1_bit.P1IS
    #define EXTI_CR1_P2IS EXTI_CR1_bit.P2IS
    #define EXTI_CR1_P3IS EXTI_CR1_bit.P3IS

    #define EXTI_CR2_P4IS EXTI_CR2_bit.P4IS
    #define EXTI_CR2_P5IS EXTI_CR2_bit.P5IS
    #define EXTI_CR2_P6IS EXTI_CR2_bit.P6IS
    #define EXTI_CR2_P7IS EXTI_CR2_bit.P7IS

    In my Case ive got the LEDs on PE7 and PC7 and a Button on PC1
    (On STM8L-Discovery)
    Im a newbie in programming STM MCUs.

    I would be proud if somebody can help me.
    I only want to let a LED Blink when i press a button using Interrupts.
    Like you did.
    http://blog.mark-stevens.co.uk/category/stm8/

    Thanks in Advance

    • vikas says:

      hello sir
      you are helping so much . but can you please help me with internal rtc of stm8l152c6 to configure it.

      • Mark says:

        Glad you are finding the series of posts useful. Unfortunately I do not have the microcontroller you have quoted and I have not used the RTC as the STM8S chip I am using does not have this feature enabled.

        I wish you all the best in finding a solution to you problem,
        Mark

  12. ashvini says:

    hi mark
    writing from new delhi india,
    i understand that you are using IAR wk’bench.
    question is – how on earth are you able to access indivisual bits of STM8 GPIO registers ?
    afaik, STM8 GPIO memory is not bitmapped. so how are you able to write somthing like CLK_ICKR = 0 ??

    is this some secret of the IAR compiler ?
    could you possibly share your register bit definitions file ?

    regards
    ashvini

  13. ashvini says:

    sorry, i wrote ‘GPIO registers’ above by mistake.
    it should read ‘all STM8 registers’
    my apologies.
    ashvini

  14. Sean says:

    This is a fantastic post:
    http://blog.mark-stevens.co.uk/2011/02/silverlight-on-the-netduino/

    We’ve being trying to draw more attention to great Internet of Things related posts. Would you be interested in posting it on CodeProject (10 million members) to get more eyes on it?

    Please email me at sean[at]codeproject.com if you are interested, or if you have further questions.

  15. Arash Kazemi says:

    Hi Mark,
    First, let me thank you for your magnificent website, which has been the best resource I have found on developing for STM32 and STM8, and have used it a lot.

    I am currently working on a project using STM32F103R8, and I have problem securing it. I use a JLink programmer/debugger, and when I use the Secure Chip option in JFlash, the chip stops working. I have no clue about the reason. Could you please give me some hints? I used to work with AVR family, they have some lock bits which prevent reading the flash content when set, but seems like that is not the case in STM32. I have searched a lot but couldn’t find anything, that’s why I am asking you. Thanks a lot.

  16. Maxime says:

    Hello Mark,

    I’ve discovered your blog through your posts about the TLC5940.
    ( http://blog.mark-stevens.co.uk/2011/10/tlc5940-16-channel-pwm-driver/ )

    First of all thanks for this documentation, which is the most precise I could find about external clock and Tlc5940.
    I’ve been running a Tlc5940 with an Arduino, and got stucked because of the small speed of pwm write on the arduino to control the GSCLK. That’s why i’m currently looking for solutions to make it quicker and found your blog.
    All this circuit part, with crystal and everything is really new to me, so, soryy if my question is a bit silly…
    In your circuit diagram, we see that your controller blank pin is connected to the 74HC32, but I thought the blank was sent automatically every 4096 pulse by the combination of the crystal and the 74HC4060. Do you still need to send the blank with your program?

    Hope you will read me, and thanks again for this great documentation.

    • Mark says:

      Glad you find this information useful.

      You do not need to send the blank signal from your application. You can rely on the counter to trigger the blank pulse at the right time. The reason I added the OR gate was so that if a slow clock was being used and the application wanted an instant reset then it could be supplied from the micro-controller. You can remove the gate and the signal from the micro-controller if you want. With the 8MHz clock circuit I designed it is a bit of overkill.

      All the best with your project,
      Mark

  17. Ted Jones says:

    I am starting an STM32L15x project using a CooCox IDE. One area is a radio link so I’m going to use a Microchip MRF24J40MA Zigbee module but purely for point to point 2 way comms. So my aim was to use a Microchip stack, the MiWi P2P protocol, however I believe that this is only licenced for PIC microcontrollers.

    The MRF24J40MA uses an SPI bus with three I/O lines (INT, WAKE and RESET) so changing the SPI code from PIC to STM32 should be possible. Any ideas or tips? Thanks.

    Ted Jones

  18. Wolfgang Kurz says:

    Hello Mark,

    i saw your excellent Example to communicate with your Netduino over USB with Windows Forms. I need also windows form for my netduino plus 2 application wich works with the serial port. I am new to c# and windows froms either, so i wanted u to ask if u can help me if I send u my programming code wich is not very big and easy to explain. Or can u give me an easy tutorial, how to link buttons with ur netduino events or smth like that.
    Thanks in advance!

    Greets

    Wolfgang Kurz

  19. Marcelo says:

    Hi there, your site is very good! please, what is the compiler that you used in the examples for STM8 microcontrollers? Tks1!

    • Mark says:

      Thank you, the STM8S section of the site has been an interesting journey.

      I use the IAR free compiler, it is good for 8K of code, after that you need to purchase a licence. I have not run into any limits so far.

      Regards,
      Mark

  20. Jack says:

    Hello Mark
    I have a problem about UART RX interrupt. would you pls. would you pls put a example in your website or give me an email to me so i can share my code with you ?

    Regards
    Jack

  21. Rin says:

    Hello
    There ‘s a mistake in your article here: http://blog.mark-stevens.co.uk/2015/05/stm8s-i2c-slave-device/
    You wrote:
    I2C_OARH_ADD = 0; // Set this device address to be 0x50.
    I2C_OARL_ADD = 0x50;

    If your slave’s address is 0x50 then OARL register content should be 0x50<<1.
    This mistake makes me waste two day until I notice it in the reference sheet. Well I'm in the wrong for not read the doc carefully.

    Anw your blog helped me a lot ! Thank you.

  22. Mehrdad says:

    Hi Mark,
    First, let me thank you for your magnificent website,
    which has been the best resource I have found on
    developing for STM8l, and have used it a lot.

    I am currently working on a project using STM8l151C6.
    I use a STVD and Cosmic debugger, and want to
    use the micro in low power run mode but I have problem.
    I have no clue about the reason. Could you please
    give me some hints? I used to work with AVR family,
    but seems like that is not the case in STM8l.
    I have searched a lot but couldn’t find anything,
    that’s why I am asking you.
    Thanks a lot.

    • Mark says:

      Thank you for your appreciation of this site. I’m glad you find it useful.

      On the STM8S I’d be looking at section 10 of RM0016, The reference manual. Specifically section 10.2 in order to work out which power saving mode would be applicable to me. I have never looked at the power saving features before so I can only suggest what I would look at. If I was looking for the maximum power saving and no processing required unless interrupted then I would be thinking about using the halt statement (I think this would be the __halt() instruction in IAR’s environment). I believe you would need to be using the internal HSI for this to work. I also think you need to looking at disabling the main voltage regulator (REGAH bit in the CLK_ICKR register).

      Hope this helps,
      Mark

  23. Niczko says:

    Looked at your STM8S I2C slave mode example, thanks for posting it.

    A quick note: you don’t need to set timing details (I2C->FREQR, I2C->CCRH, I2C->CCRL, I2C->TRISER) when the peripheral is only operating in slave mode.

    I think that setting these registers in this tutorial is confusing, because that seems to defeat the purpose of a synchronous communication where the receiver doesn’t need to know about the incoming data rate (at the expense of a separate clock line).

    • Mark says:

      Thank you for taking the time to point this out, I’ll bear this in mind in future.

      Regards,
      Mark

      • Niczko says:

        Also, it seems you don’t handle the STOP condition in your interrupt routine.
        As a result, the micro will endlessly reenter the interrupt routine (because the flag STOPF in register I2C->SR1 is never cleared).

  24. Arko says:

    Hi, Is it really needed to set registers to their init value after boot/reset?
    Isn’t POR takes care about that? (I also saw the overuse of Deinit() from lib).

    Thanks,
    Arko

  25. Nick HIll says:

    Hi. Thank you for putting up example code for the STM8. I am just getting started with this micro.

    I have installed STVD and COSMIC compiler. I have gotten as far as to create LED flasher from scratch,.

    It must be because I have just started with this micro, and don’t understand how the STM8 world works yet… but it really seems to me that each compiler comes with it’s own version of headers for a particular part… and each vendor choses a different name for the ports. And Cosmic doesn’t appear to set names for special purpose bits as bolean values in SFRs.

    Of course this kills code portability stone dead, and any C code to be valid for the micro would need the same vendor’s header file and moving from one vendor to another would either force re-learning of SFR names, or for the user to write their own compatibility headers.

    I’m not sure where to go from here. I am truly loathed to write code against a specific vendor’s non-redistributable headers. I have written my own header for port bits for the “Hello World” LED flasher, but surely this isn’t really how to get started with this micro. Have I got it all wrong? Perhaps you can advise?

    Thanks.

  26. Robothito says:

    Hello. Great tutorials.
    I have been working with the STM8 just recently. And I found your post on GPIO
    http://blog.mark-stevens.co.uk/2012/08/664/

    I have two questions:
    1) in the first picture
    http://blog.mark-stevens.co.uk/wp-content/uploads/2012/07/SimpleGPIOBreadboard.jpg

    What is the yellow cable in the left (near the NRST pin I guess-in green)? This cable is going left and it seems to be connected to the ground black cable… can you explain please?

    2) You don’t put any wiring to the NRST pin? I figure it out that some capacitor , a resistor and maybe a switch would be needed…

    Would appreciate very much a reply on these

    Thanks

    • Mark says:

      Glad you like the tutorials.

      The yellow cable is actually the GPIO pin that is being toggled and this is going to my oscilloscope. It is not connected to the crocodile clip but goes under the clip to the scope probe. You can just see this in the top left of the picture. Sorry it’s not the best picture.

      The green lead is actually connected to NRST – if you follow the connection it goes to the NRST connection on the ST-Link/V2.

      Regards,
      Mark

  27. sravanakumar says:

    sir which IDE you are using for STM 32 processor

    • Mark says:

      Until last year I was using he CooCox IDE (http://www1.coocox.org/CooCox_CoIDE.htm). This is a free development environment based upon Eclipse and GCC. It’s actually fairly good.

      My IDE of choice is Visual Studio and there is a reasonably priced add-on for the Community Edition of Visual Studio that can compile for a number of microcontrollers including the STM32. The add-on is VisualGDB (http://www.visualgdb.com/) and the next time I do any development with the STM32 I’ll be using this combination, Visual Studio + VisualGDB.

      Hope this helps,
      Mark
      —-
      Twitter: @nevynuk

  28. costel stratulat says:

    Hello Mr Mark Stevens ‎. I really need your help and i will greatly appreciate it if you can spare some time to help me out . I am a totaly newbie in prgramming and its imposible for me to write a program for a stm 8s .

    here is my problem: I have a rc bait boat with proprietary software and hardware. The boat propulsion are two brushed dc motors wich are working in forward or reverse mode by using two relays to swap the polarity of the motors . I need to upgrade the motors with brushless type motors , i have also two esc to drive these motors but i dont have any pwm signal to drive the esc. here it comes my problem . the mcu of the board is a atmel , it uses 3volt to gnd to power up the motors and drive forward ( i believe that the mcu signal is used to trigger some p channel mosfets. To go in reverse mode, the mcu trigger the relay to swap polarity of the motors and then it does the same thing , 3volt to gnd to power up the motors to full speed .

    My question : is it posible to use these 3 volts as a reference voltage and the relay trigger signal to create a pwm signal , so i can drive the esc of the brushless motors ?

    Thank you very much for your time .. with all my respects Costel Stratulat .

    • Mark says:

      I’m sorry but I have no experience using motors / ESC etc. and so I am unable to help at this time.

      Good luck with your project.
      Mark

  29. Keith Fleming says:

    Hi Mark! This site is brilliant. It has helped me get up to speed on the STM8S103 despite the lack of Arduino support for it in their IDE. So I am getting proficient with “bare metal” software development and you have been a great help.

    My question relates to reading an I2C register as a way of clearing a condition, example your I2C-Master example code, in the interrupt service routine:

    if (I2C_SR1_SB) {
    //
    // Master mode, send the address of the peripheral we
    // are talking to. Reading SR1 clears the start condition.
    //
    reg = I2C_SR1;
    //
    // Send the slave address and the read bit.
    //
    I2C_DR = (DEVICE_ADDRESS << 1) | I2C_READ;

    My question is, doesn't the test for the SB bit being set perform the task of reading the register, making the "reg = I2C_SR1" line unnecessary? I'm not suggesting you rewrite the code. It is just my curiosity is "at what point does the CPU recognize that the register has been read". Or perhaps the compiler you are using does something tricky like checking bit 0 of the register and "reg = I2C_SR1" does a full-blown transfer of register contents to one of the CPU's registers. I'm using SDCC (not a high-price IDE). Thanks for any insights!

    • Mark says:

      Sorry for the delay in replying, the day job has been manic recently.

      Looking at the code I think you are right about the read.

      Glad you have found the site useful.

      Regards,
      Mark

  30. rasoul sepehr says:

    hello.
    I have a problem in jump to flash address on method.

    #include

    #pragma location = 0x9000

    void VoidInLocation9000(void)
    {
    //printf …
    }

    int main()
    {

    //delay_ms 1000

    asm(“JP $9000”);

    while (1)
    {
    }
    }

    pleas help me!.. 🙁
    thenks!

  31. Louis Luyckx says:

    Hello Mr Mark Stevens,

    I have read about your weather station project.
    I want to make also a weather station.
    I’s it a problem to get help when necessary?
    I’m from Belgium. Your name sounds like a Dutch name!

    Regards

    Louis

  32. Louis Luyckx says:

    Hello Mark,

    A few days ago I left a message but did not get a reply.
    Maybe something was wrong, so I try again.
    I’m busy with making an arduino project. I want to read out several sensor
    and write these values every 4 hours to the sd-card. So far no problem with reading and writing to the sd-card and adding a time stamp of the writing time.
    Now I want to add a reed switch and count all the pulses between every 4 hours and also write it to the sd-card with the same time and date like I write the other values.
    The problem is that in the main time i must store all the pulses coming from the reed switch between this 4 hours and read them out with same seqeunce i read the other sensors (every 4 hours)
    I was thinking to store the pulse to the eeprom and keep only the latest value in the memory and read that value out when the 4 hours are over.

    Most thanks for your reply

    • Mark says:

      I had a similar problem with the pluviometer on the project. I first started to look at using a 7400 series counter to count the pulses. This would be left running whilst the ESP8266 went to sleep. I would then read the pulses when the ESP8266 woke up. This required a number of lines to read the state of the counter and I simply started to run out of GPIOs.

      The solution I have settled on is to add a second microcontroller to the system. This is very low power and simply counts the pulses. I am then going to communicate with the ESP8266 over I2C. The ESP8266 requests the pulse count from the second micrcontroller when it wants to take a reading. It also has the ability to zero the counter when necessary.

      Hope this helps,
      Mark

  33. Gee says:

    Hi, I am having trouble sending out a PWM signal on PC4 (STM8S003F3 which is Timer 1 Channel 4). Your example code works for PD4 (Timer 2 channel 1). Though I need it on PC4.

    I made some changes such as renaming TIM2xxx to TIM1xxx.

    Apparently, Timer 1 doesn’t have a prescaler, CCER4, etc.

    How would you even select the channel?

    Thanks for your time

    • Gee says:

      This is what I have in the setupTimer function

      //TIM1_PSCR = 0x00; // Prescaler = 1.
      TIM1_ARRH = 0xc3; // High byte of 50,000.
      TIM1_ARRL = 0x50; // Low byte of 50,000.
      TIM1_CCR4H = 0x30; // High byte of 12,500
      TIM1_CCR4L = 0xd4; // Low byte of 12,500
      TIM1_CCER2_CC4P = 0; // Active high.
      TIM1_CCER2_CC4E = 1; // Enable compare mode for channel 1
      TIM1_CCMR4_OC4M = 6; // PWM Mode 1 – active if counter < CCR1, inactive otherwise.
      TIM1_CR1_CEN = 1; // Finally enable the timer.

    • Gee says:

      Sorry I just checked your “Single Pulse Generation with the STM8S”

      I see you are using the Timer1 Channel 4

      Though I am not sure why there is a big difference between the two timers

  34. Paul M says:

    Hi Mark-

    I found you through the netduino forums. I’m an ME trying to support a product that we built using a Netduino Mini. It looks like they’re no longer made so I’m looking at having them produced using the opensource files. I’m currently trying to run down all the required firmware and not having much success. Do you know anyone in the NetDuino community that could help, or that does consulting?

    Regards,

    Paul M

  35. Emile says:

    Mark,

    Thanks for the site, it got me up-to-speed with STM8 programming real fast! I have an update w.r.t. your blog ‘storing data in eeprom on the STM8s’. You mentioned that you needed a couple of tries before data was stored. I think I found the problem: the reference manual states that you must check that the DUL bit is effectively set. So if you add the following line (after having written the MASS keys and before writing the data itself):

    while (FLASH_IAPSR_DUL == 0) ; // wait until EEPROM is unlocked

    Then all is good. It apparently takes a bit of time before the EEPROM is unlocked. Hope this helps!

    Regards,

    Emile

    • Mark says:

      Thank you for the advice, I will work the modification into my future projects.

      Glad you found the blog useful, it has been a labour of love.

      Regards,
      Mark

  36. Johan Smit says:

    Hi Mark,
    In gratitude for all the helpful code you publish, I would like to send you the code I wrote for Interrupt bit bang serial for STM8S103. I looked all over for an example and found none. Therefore I wrote it, and it may be helpful to others.
    How can I send you the tested code please?
    Thank you
    Johan Smit

  37. Mohammad Shoghi says:

    Hello.
    I’m Mohammad from Iran. Thank You for your useful blog Mr.Stevens.
    I have problem about one of your post with “STM8S Timers” name. (with SPL).
    In this post you did select internal clock source with 16MHz frequency that it used directly as input clock of timer 2. the period of 16MHz is 0.0000625 miliSecond !
    that means when we select 4096 prescaler for our timer ; the ISR frequency should be 0.256 ( 4096 * 0.0000625 ) and final frequency ( on GPIO Pin ) should be approximately half miliSecond ( 2 * 0.256 = 0.512 ).
    my calculation is different with your results.
    could you please more explain for me.
    best regards.

  38. Marko says:

    There is a bug in the “SPI and the STM32” tutorial that must be fixed.

    There will be problems if you only send one byte by DMA. Then the DMA2_Stream5_IRQHandler() could be executed before BSY flag is set to one. Then the cip select would be set high before the data is sent.

    This only happened to me when i used SPI1 and SPI2 at the same time.

    To fix this you must add a while statement that waits until SPI SR RXNE is one. Then wait for BSY to be zero.

    And you should also clear the OVR bit in DMA2_Stream5_IRQHandler()

  39. I received word that you are enjoying utilizing Syncfusion’s free product offerings. I wanted to reach out and see if you were interested in becoming a guest blogger for Syncfusion. By providing your story, you not only create exposure for you and your company, but an avenue to showcase your application to the developer community. From this mutual support, we learn more about developers like yourself and how you use our flexible controls to create these outstanding applications.

    Please let me know if you are interested in creating a blog post about your experience with Syncfusion’s products.

  40. Manue says:

    do you think is posible to use your code in a serie of videos in spanish for youtube?

    • Mark says:

      Yes, please feel free to use the code from my web site in your YouTube videos.

      Would you please send me a link to the videos when they are posted. I am interested to see how my work is being used.

      Regards,
      Mark

  41. Robert Metzner says:

    Hello Mark: I thoroughly enjoyed your writeup of the DS3234, it is by far the most WELL DOCUMENTED code I’ve come across. It’s amazing what trash you can find on GitHub! I was looking for “alarm flag clearing” when I came across your blog. That being said, I am working on an Enteral Feed Pump for Tube Feed Patients and decided to start with the ESP32. I am driving an SPI display with it for the UI. I chose the ESP32 for its wireless connectivity right out of the box, and it isn’t memory constrained as are many Arduino products. I’m successfully using Visual Studio with the Visual Micro port to Arduino. I was a bit disappointed you used “BitBang” to emulate the SPI since it’s bound to be much slower. Best Regard, Bob Metzner

    • Mark says:

      Bob,

      Glad you found the documentation useful. I try to only post working projects or updates to projects that are in flight.

      Regarding the BitBang, this was a quick fix to get the code going. The long term aim was to abstract the code into the clock module, the memory module and a transport provider. The clock and memory modules were going to be abstracted to allow for me to use the same code to be run on a DS3231 and DS3234. the former does not have any memory by default. The transport provider would allow the use of SPI, BitBang or I2C. It’s just that I have not managed to complete the work. It should be a simple case of changing the methods at the top of the file to implement SPI.

      I like the ESP32 as well, as you say, plenty of memory and WiFi built in. Really useful. I see that there are a couple of tutorials out there covering debugging in Eclipse as well.

      All the best with your projects.

      Regards,
      Mark

  42. Subin says:

    Sir,

    Thank you for taking the effort in writing a blog for the STM8S.

    I am trying to learn to use the STM8S105 Disovery board. I would like to know if I must use the Standard Peripheral Library or should I use Direct Register Manipulation to program? On reading your posts, I saw that the Library has a few bugs.
    Which method do you recommend, keeping in mind that I am a newbie to microcontrollers with a little experience on the Arduino.

    Thank You.
    Subin

    • Mark says:

      Subin,

      If you are new to Microcontroller development I would look at using the Standard Peripheral Library. This will abstract you from a lot of the detail.

      Regards,
      Mark

      • Subin says:

        Sir,
        Thank you for responding, and for the advice.

        At what point should I start using Direct Register Manipulation?

        And would you recommend STVD or IAR EWSTM8?

        Thank you,
        Subin

  43. bill says:

    Hi,
    Thank you for your work. I found in using a usb-serial adaptor that I had to clear/reset/make _as_input the PD6_DDR of the stm8 in order to get hi enough voltage
    My normal setup is to set all GPIO’s as outputs and I was getting very low voltage on the RX (PD6) pin, about 1.6 V, until I set it to input, which now gives 3+ volts on high.
    Bill

  44. Ali says:

    Hi
    You have a very good website and has usefull information and hrlping me in very aspects .
    Now I am working with stm8s003f3p6 and when I need some hint and software routine I check you website .
    Today I wanted to check the stm8s power down and auto wake up . I used your routine it is working ., but current in sleep is 65 ua .
    I have aquestion about the power down current of stm8s . In stm8s and stm8a refference pdf file about sleep and power down it is written that is possible to set the stm8s to draw 5 ua in hakt mode and near 9 ua in active halt mode , but I can not reach to this state . When the stm8s goes to poer down it draws 65 ua , how is possible to reduce it to 5 ua , have you ever checked this subject ?
    Should be done any special thing to have 5 ua current in complete power down(halt) mode ?

    Thanks a lot

  45. Emile says:

    Mark,

    Have you ever tried UART communications with both send and receive? On polling basis? I used your source code and sending is not a problem, it works fine. But when I try to receive something, it reads 0xff continuously.

    The input line clearly shows a character coming in (on the oscilloscope), and the RXNE bit is set, but reading UART1_DR only gives you 0xff.

    Regards,

    Emile

  46. Chayan Roy says:

    Hello Sir,
    I am doing some programming on smt8s003f3p6, I am developing and wifi and IR based light switch. Here is my code,

    #include “STM8S003F3P.h”

    #define SHORT_MIN 444
    #define SHORT_MAX 850
    #define LONG_MIN 850
    #define LONG_MAX 1600

    #define STATE_START1 0
    #define STATE_MID1 1
    #define STATE_MID0 2
    #define STATE_START0 3
    #define STATE_BEGIN 4
    #define STATE_ERROR 5

    void InitialiseSystemClock(void);
    void RC5_Init(void);
    void commandapply(void);
    void RC5reset(void);
    void MemoryWrite(void);
    void MemoryRead(void);
    void delay_ms(unsigned int x);
    void UART1_Initialize(void);
    void UART1_TX_Init(void);
    void UART1_Print(unsigned char * message);

    unsigned int time=0,command,delay=0,t,previousbit;
    unsigned char EdgeNumber=0,x;
    unsigned char trans[4] = {0x01, 0x91, 0x9b, 0xfb};
    volatile char state,newstate;
    unsigned char event=1;
    unsigned char duty[5]={20,18,15,12,8 };
    unsigned char counter=14,k,i,j,flag=0;
    unsigned char COUNT=1,FAN_STATUS=0,LIGHT_STATUS1=0,LIGHT_STATUS2=0,LIGHT_STATUS3=0,LIGHT_STATUS4=0,CURRENT_STATUS1=0,PREVIOUS_STATUS1=0,CURRENT_STATUS2=0,PREVIOUS_STATUS2=0,CURRENT_STATUS3=0,PREVIOUS_STATUS3=0,CURRENT_STATUS4=0,PREVIOUS_STATUS4=0,CURRENT_STATUS5=0,PREVIOUS_STATUS5=0;

    unsigned char *ptr1=(unsigned char *)0x4010;
    unsigned char *ptr2=(unsigned char *)0x4011;
    unsigned char *ptr3=(unsigned char *)0x4012;
    unsigned char *ptr4=(unsigned char *)0x4013;
    unsigned char *ptr5=(unsigned char *)0x4014;
    unsigned char *ptr6=(unsigned char *)0x4015;
    unsigned char *ptr7=(unsigned char *)0x4016;
    unsigned char *ptr8=(unsigned char *)0x4017;
    unsigned char *ptr9=(unsigned char *)0x4018;
    unsigned char *ptr10=(unsigned char *)0x4019;
    unsigned char *ptr11=(unsigned char *)0x4020;

    void delay_ms(unsigned int x){

    unsigned int P;
    for(P=0;P<=x;P++);

    }
    void UART1_Initialize(void){

    UART1_CR1=(0<<4);
    UART1_CR1=(0<<2);
    UART1_CR3=(0<<3)|(0<<4)|(0<<5);
    UART1_BRR2=0X0a;
    UART1_BRR1=0x08;

    UART1_CR2=0x24;

    }
    void UART1_Print(unsigned char * message){

    char *ch = message;

    while (*ch)
    {

    UART1_DR = (unsigned char) *ch; // Put the next character into the data transmission register.

    while (!(UART1_SR & (1<<7))); // Wait for transmission to complete.

    ch++; // Grab the next character.

    }

    }
    void main(void){

    unsigned char temp;

    InitialiseSystemClock();
    UART1_Initialize();
    CFG_GCR =(1<<0);
    MemoryRead();

    PD_DDR &=~(1<<6);
    PD_CR1 |=(1<<6);

    /* SWITCH PORT */

    /* PB_DDR &=~(1<<4);
    PB_CR2 |=(1<<4);

    PB_DDR &=~(1<<5);
    PB_CR2 |=(1<<5);

    PA_DDR &=~(1<<1);
    PA_CR2 |=(1<<1);

    PA_DDR &=~(1<<2);
    PA_CR2 |=(1<<2);

    PA_DDR &=~(1<<3);
    PA_CR2 |=(1<<3);

    /*FAN PORT */
    PC_DDR |=(1<<5);
    PC_CR1 |=(1<<5);
    PC_CR2 |=(1<<5);

    PC_DDR |=(1<<6);
    PC_CR1 |=(1<<6);
    PC_CR2 |=(1<<6);

    PC_DDR |=(1<<4);
    PC_CR1 |=(1<<4);
    PC_CR2 |=(1<<4);

    /* LIGHT PORT */
    PC_DDR |=(1<<7);
    PC_CR1 |=(1<<7);
    PC_CR2 |=(1<<7);

    PC_DDR |=(1<<3);
    PC_CR1 |=(1<<3);
    PC_CR2 |=(1<<3);

    PD_DDR |=(1<<2);
    PD_CR1 |=(1<<2);
    PD_CR2 |=(1<<2);

    PD_DDR |=(1<<3);
    PD_CR1 |=(1<<3);
    PD_CR2 |=(1<<3);

    EXTI_CR1=0b11001111;

    PD_ODR &=~(1<<2);
    PD_ODR &=~(1<<3);
    PC_ODR &=~(1<<3);
    PC_ODR &=~(1<<4);
    PC_ODR &=~(1<<5);
    PC_ODR &=~(1<<6);
    PC_ODR &=~(1<<7);

    RC5_Init();

    if(LIGHT_STATUS1==1){
    delay_ms(1000);
    PC_ODR |=(1<<7);

    }
    if(LIGHT_STATUS1==0){
    PC_ODR &=~(1<<7);

    }
    if(LIGHT_STATUS2==1){

    delay_ms(1000);
    PC_ODR |=(1<<3);

    }
    if(LIGHT_STATUS2==0){

    PC_ODR &=~(1<<3);
    }

    if(LIGHT_STATUS3==1){
    delay_ms(1000);
    PD_ODR |=(1<<2);

    }
    if(LIGHT_STATUS3==0){
    PD_ODR &=~(1<<2);

    }
    if(LIGHT_STATUS4==1){
    delay_ms(1000);
    PD_ODR |=(1<<3);

    }
    if(LIGHT_STATUS4==0){
    PD_ODR &=~(1<<3);
    (1<<3);

    }

    if(FAN_STATUS==1){

    if(COUNT==1){
    delay_ms(1000);
    PC_ODR |=(1<<5);
    PC_ODR &=~(1<<4);
    PC_ODR &=~(1<<6);

    }
    if(COUNT==2){
    delay_ms(1000);
    PC_ODR &=~(1<<5);
    PC_ODR |=(1<<4);
    PC_ODR &=~(1<<6);

    }
    if(COUNT==3){
    delay_ms(1000);
    PC_ODR |=(1<<4);
    PC_ODR |=(1<<5);
    PC_ODR &=~(1<<6);

    }
    if(COUNT==4){
    delay_ms(1000);

    PC_ODR &=~(1<<4);
    PC_ODR &=~(1<<5);
    PC_ODR |=(1<<6);

    COUNT=4;
    }
    }
    if(FAN_STATUS==0){

    PC_ODR &=~(1<<4);
    PC_ODR &=~(1<<5);
    PC_ODR &=~(1<<6);

    }

    _asm("rim");

    while(1){

    /*
    while(!(UART1_SR & (1<<5)));
    temp=UART1_DR;

    if(temp==0x07){

    PC_ODR &=~(1<<5);
    PC_ODR &=~(1<<4);
    PC_ODR &=~(1<<6);
    }
    if(temp==0x01){
    PC_ODR ^=(1<<7);

    }
    if(temp==0x06){
    PC_ODR ^=(1<<3);

    }
    if(temp==0x02){
    PC_ODR |=(1<<5);
    PC_ODR &=~(1<<4);
    PC_ODR &=~(1<<6);

    }

    if(temp==0x03){
    PC_ODR &=~(1<<5);
    PC_ODR |=(1<<4);
    PC_ODR &=~(1<<6);

    }
    if(temp==0x04){
    PC_ODR |=(1<<4);
    PC_ODR |=(1<<5);
    PC_ODR &=~(1<<6);

    }

    if(temp==0x05){
    PC_ODR &=~(1<<4);
    PC_ODR &=~(1<<5);
    PC_ODR |=(1<<6);

    } */

    }

    }

    void MemoryRead(void){

    unsigned char b,c;
    if(!(FLASH_IAPSR & (1<<3))){

    FLASH_DUKR=0XAE;
    FLASH_DUKR=0X56;

    FAN_STATUS=*ptr1;
    COUNT=*ptr2;
    LIGHT_STATUS1=*ptr3;
    LIGHT_STATUS2=*ptr4;
    LIGHT_STATUS3=*ptr5;
    LIGHT_STATUS4=*ptr6;
    PREVIOUS_STATUS1=*ptr7;
    PREVIOUS_STATUS2=*ptr8;
    PREVIOUS_STATUS3=*ptr9;
    PREVIOUS_STATUS4=*ptr10;
    PREVIOUS_STATUS5=*ptr11;
    FLASH_IAPSR &=~(1<<3);

    }

    }

    void MemoryWrite(void){

    if(!(FLASH_IAPSR & (1<<3))){

    FLASH_DUKR=0XAE;
    FLASH_DUKR=0X56;

    *ptr1=FAN_STATUS;
    *ptr2=COUNT;
    *ptr3=LIGHT_STATUS1;
    *ptr4=LIGHT_STATUS2;
    *ptr5=LIGHT_STATUS3;
    *ptr6=LIGHT_STATUS4;
    *ptr7=PREVIOUS_STATUS1;
    *ptr8=PREVIOUS_STATUS2;
    *ptr9=PREVIOUS_STATUS3;
    *ptr10=PREVIOUS_STATUS4;
    *ptr11=PREVIOUS_STATUS5;

    FLASH_IAPSR &=~(1<<3);

    }

    return;

    }

    @far @interrupt void TIMER4_INTERRUPT (void){

    }
    @far @interrupt void TIMER1_INTERRUPT (void){

    return;

    }
    @far @interrupt void TIMER2_INTERRUPT (void){

    time++;

    TIM2_SR1 &=~(1<<0);
    return;

    }

    @far @interrupt void PortC_external_interrupts (void){

    }

    @far @interrupt void PortB_external_interrupts (void){

    if(PB_IDR & (1<<4)){

    CURRENT_STATUS1=1;

    }
    else{

    if(!(PB_IDR & (1<<4))){

    CURRENT_STATUS1=0;

    }

    }

    if(PREVIOUS_STATUS1 !=CURRENT_STATUS1){

    delay_ms(1000);
    PC_ODR^=(1<<7);
    LIGHT_STATUS1^=1;

    }
    PREVIOUS_STATUS1=CURRENT_STATUS1;

    if(PB_IDR & (1<<5)){

    CURRENT_STATUS2=1;

    }
    else{

    if(!(PB_IDR & (1<<5))){

    CURRENT_STATUS2=0;

    }

    }

    if(PREVIOUS_STATUS2 !=CURRENT_STATUS2){

    delay_ms(1000);
    PD_ODR^=(1<<1);
    LIGHT_STATUS2^=1;

    }
    PREVIOUS_STATUS2=CURRENT_STATUS2;

    MemoryWrite();
    return;

    }

    @far @interrupt void PortA_external_interrupts (void){

    if(PA_IDR & (1<<1)){

    CURRENT_STATUS3=1;

    }
    else{

    if(!(PA_IDR & (1<<1))){

    CURRENT_STATUS3=0;

    }

    }

    if(PREVIOUS_STATUS3 !=CURRENT_STATUS3){

    delay_ms(1000);
    PD_ODR^=(1<<2);
    LIGHT_STATUS3^=1;

    }
    PREVIOUS_STATUS3=CURRENT_STATUS3;

    /*———————————*/

    if(PA_IDR & (1<<2)){

    CURRENT_STATUS4=1;

    }
    else{

    if(!(PA_IDR & (1<<2))){

    CURRENT_STATUS4=0;

    }

    }

    if(PREVIOUS_STATUS4 !=CURRENT_STATUS4){

    delay_ms(1000);
    PD_ODR^=(1<<3);
    LIGHT_STATUS4^=1;

    }
    PREVIOUS_STATUS4=CURRENT_STATUS4;

    /*—————————————*/
    if(PA_IDR & (1<<3)){

    CURRENT_STATUS5=1;

    }
    else{

    if(!(PA_IDR & (1<<3))){

    CURRENT_STATUS5=0;

    }

    }

    if(PREVIOUS_STATUS5 !=CURRENT_STATUS5){

    FAN_STATUS^=1;

    RC5reset();

    }
    PREVIOUS_STATUS5=CURRENT_STATUS5;

    MemoryWrite();

    return;

    }
    @far @interrupt void PortD_external_interrupts (void){

    TIM2_CR1=(1<<0);

    delay=time;

    if(state==STATE_BEGIN){

    counter–;
    command |=1<<counter;

    state=STATE_MID1;

    delay=0;

    time=0;

    TIM2_CR1=(1<<0);

    return;

    }

    if((PD_IDR & (1<<4))){

    event=2;

    }else{

    if(!(PD_IDR & (1<LONG_MIN & delay<LONG_MAX){

    event=event+4;

    }

    else if(delay SHORT_MAX)
    {
    /* If delay wasn’t long and isn’t short then
    * it is erroneous so we need to reset but
    * we don’t return from interrupt so we don’t
    * loose the edge currently detected. */
    RC5reset();
    return;
    }

    newstate = (trans[state]>>event) & 0x03;

    state=newstate;

    if(state == STATE_MID0)
    {

    counter–;
    }

    else{
    if(state==STATE_MID1){

    counter–;

    command |=1<<counter;

    time=0;

    }
    }

    if(counter==0 && (state==STATE_START1 || state==STATE_MID0)){

    PD_CR2 &=~(1<<4);

    commandapply();

    }

    time=0;

    delay=0;

    return;

    }

    void commandapply(void){

    t=command &0x800;

    if(x==0){

    previousbit=t;
    x=1;

    }
    if(t !=previousbit){

    /*All OFF */
    if(command==0b11001101000100){
    PD_ODR &=~(1<<3);
    PD_ODR &=~(1<<2);
    PC_ODR &=~(1<<3);
    PC_ODR &=~(1<<7);
    LIGHT_STATUS1=0;
    LIGHT_STATUS2=0;
    LIGHT_STATUS3=0;
    LIGHT_STATUS4=0;

    FAN_STATUS=0;

    }
    if(command==0b11101101000100){
    PD_ODR &=~(1<<3);
    PD_ODR &=~(1<<2);
    PC_ODR &=~(1<<3);
    PC_ODR &=~(1<<7);

    LIGHT_STATUS1=0;
    LIGHT_STATUS2=0;
    LIGHT_STATUS3=0;
    LIGHT_STATUS4=0;
    FAN_STATUS=0;
    }
    /*F ON/OFF */
    if(command==0b11001101101001){

    FAN_STATUS^=1;

    }
    if(command==0b11101101101001){

    FAN_STATUS^=1;
    }

    /*L1 On-Off */
    if(command==0b11001101100010){

    LIGHT_STATUS1^=1;
    if(LIGHT_STATUS1==1){
    delay_ms(1000);
    PC_ODR |=(1<<7);

    }
    if(LIGHT_STATUS1==0){
    PC_ODR &=~(1<<7);

    }

    }
    if(command==0b11101101100010){

    LIGHT_STATUS1^=1;
    if(LIGHT_STATUS1==1){
    delay_ms(1000);
    PC_ODR |=(1<<7);

    }
    if(LIGHT_STATUS1==0){
    PC_ODR &=~(1<<7);

    }
    }

    /*L2 On-Off */
    if(command==0b11001101010001){

    LIGHT_STATUS2^=1;

    if(LIGHT_STATUS2==1){

    delay_ms(1000);
    PC_ODR |=(1<<3);

    }
    if(LIGHT_STATUS2==0){

    PC_ODR &=~(1<<3);
    }

    }
    if(command==0b11101101010001){

    LIGHT_STATUS2^=1;
    if(LIGHT_STATUS2==1){

    delay_ms(1000);
    PC_ODR |=(1<<3);

    }
    if(LIGHT_STATUS2==0){

    PC_ODR &=~(1<<3);
    }

    }

    /*L3 On-Off */
    if(command==0b11001101101011){

    LIGHT_STATUS3^=1;
    if(LIGHT_STATUS3==1){
    delay_ms(1000);
    PD_ODR |=(1<<2);

    }
    if(LIGHT_STATUS3==0){
    PD_ODR &=~(1<<2);

    }

    }
    if(command==0b11101101101011){

    LIGHT_STATUS3^=1;
    if(LIGHT_STATUS3==1){
    delay_ms(1000);
    PD_ODR |=(1<<2);

    }
    if(LIGHT_STATUS3==0){
    PD_ODR &=~(1<<2);

    }

    }
    /* L4 ON?OFF */
    if(command==0b11001101000011){
    delay_ms(1000);
    LIGHT_STATUS4^=1;
    if(LIGHT_STATUS4==1){

    PD_ODR |=(1<<3);
    }

    }
    if(LIGHT_STATUS4==0){
    PD_ODR &=~(1<<3);

    }
    if(command==0b11101101000011){
    delay_ms(1000);

    LIGHT_STATUS4^=1;
    if(LIGHT_STATUS4==1){

    PD_ODR |=(1<<3);
    }
    if(LIGHT_STATUS4==0){
    PD_ODR &=~(1<=4){

    COUNT=4;
    }

    }
    if(command==0b11101101011110){

    COUNT++;
    if(COUNT>=4){

    COUNT=4;
    }

    }
    /* F– */
    if(command==0b11001101001111){

    COUNT–;
    if(COUNT<=1){
    COUNT=1;

    }

    }
    if(command==0b11101101001111){

    COUNT–;
    if(COUNT<=1){
    COUNT=1;

    }

    }
    previousbit=t;
    }

    TIM2_CR1 &=~(1<<0);
    flag=1;
    MemoryWrite();
    RC5reset();
    }
    void RC5_Init(void){

    PD_DDR &=~(1<<4);

    PD_CR2 |=(1<<4);

    TIM2_PSCR=16;
    TIM2_ARRH=0X00;
    TIM2_ARRL=0X01;
    TIM2_IER=(1<<0);

    counter=14;

    command=0;

    state=STATE_BEGIN;
    }

    void RC5reset(void){

    PD_CR2 |=(1<<4);

    command=0;

    state=STATE_BEGIN;

    counter=14;
    if(FAN_STATUS==1){

    if(COUNT==1){
    delay_ms(1000);
    PC_ODR |=(1<<5);
    PC_ODR &=~(1<<4);
    PC_ODR &=~(1<<6);

    }
    if(COUNT==2){
    delay_ms(1000);
    PC_ODR &=~(1<<5);
    PC_ODR |=(1<<4);
    PC_ODR &=~(1<<6);

    }
    if(COUNT==3){
    delay_ms(1000);
    PC_ODR |=(1<<4);
    PC_ODR |=(1<<5);
    PC_ODR &=~(1<<6);

    }
    if(COUNT==4){
    delay_ms(1000);
    PC_ODR &=~(1<<4);
    PC_ODR &=~(1<<5);
    PC_ODR |=(1<<6);

    COUNT=4;
    }
    }
    if(FAN_STATUS==0){

    PC_ODR &=~(1<<4);
    PC_ODR &=~(1<<5);
    PC_ODR &=~(1<<6);

    }

    }

    void InitialiseSystemClock(void)
    {
    CLK_ICKR = 0;
    CLK_ICKR = (1<<0);;
    CLK_ECKR = 0;
    while (!(CLK_ICKR & (1<<1)));
    CLK_CKDIVR = 0;
    CLK_PCKENR1 = 0xff;
    CLK_PCKENR2 = 0x00;
    CLK_CCOR = 0;
    CLK_HSITRIMR = 0;
    CLK_SWIMCCR = 0;
    CLK_SWR = 0xe1;
    CLK_SWCR = 0;
    CLK_SWCR = (1<<1);
    while (CLK_SWCR & (1<<0));
    }

    @far @interrupt void UART1_RECV_INTERRUPT (void){
    unsigned char temp;

    if(!(UART1_SR & (1<<5)));
    temp=UART1_DR;

    if(temp==0x07){

    PC_ODR &=~(1<<5);
    PC_ODR &=~(1<<4);
    PC_ODR &=~(1<<6);
    }
    if(temp==0x01){
    PC_ODR ^=(1<<7);

    }
    if(temp==0x06){
    PC_ODR ^=(1<<3);

    }
    if(temp==0x02){
    PC_ODR |=(1<<5);
    PC_ODR &=~(1<<4);
    PC_ODR &=~(1<<6);

    }

    if(temp==0x03){
    PC_ODR &=~(1<<5);
    PC_ODR |=(1<<4);
    PC_ODR &=~(1<<6);

    }
    if(temp==0x04){
    PC_ODR |=(1<<4);
    PC_ODR |=(1<<5);
    PC_ODR &=~(1<<6);

    }

    if(temp==0x05){
    PC_ODR &=~(1<<4);
    PC_ODR &=~(1<<5);
    PC_ODR |=(1<<6);

    }

    }

    Here , IR sensor is connected to PD4, and Wifi module TX pin is connected to RX pin i.e PD6 of stm8s mcu. Problem is wifi and Ir indivisually works fine with the controller , but when ever i am putting them together, UART1 receive doesn't work. I have seen when ever I am putting some load on PD4 pin, UART stops working. I dont' know why.I am using STVD and PD4 external interrupt is used for RC5 decoding. Please help me out. I will be very thankfull to you. Thanks.

  47. Sebastian says:

    Greetings Mr Mark

    i’m Sebastian from Colombia, Thank you so much for your useful blog, actually i’m programming the micro controller as an I2C master transmitter to communicate it with an oled display SSD1306 but i’m having some difficulties because i can not stop communication, i mean that stop condition is not generated by any method that i tried, everithing seems to be fine with the slave because the ACK signal is generated.

    so my question is ¿do you have any example for master transmitter? or what is going wrong with the code.

    if (I2C_SR1_ADDR){
    //
    // In master mode, the address has been sent to the slave.
    // Clear the status registers and wait for some data from the salve.
    //
    reg = I2C_SR1;
    reg = I2C_SR3;
    return;
    }

    if (I2C_SR1_TXE && I2C_SR1_BTF){
    I2C_CR2_STOP = 1;
    return;
    }

    if (I2C_SR1_TXE){
    I2C_DR = 0x00; // Some dummy data to send.
    return;
    }

  48. Hello Mark,

    I am working on Netduino Development Platform a couple of weeks. I have a problem about MQTT over Netduino 3 Wi-Fi. Before opening an issue on Github, I want to be sure that is a problem or not.

    I want to communicate a Netduino device with an MQTT broker. For this, I installed M2MQTT Nuget package to my project library and I wrote an example code blocks for it. My codes are looking very similar as http://forums.netduino.com/index.php?/topic/12052-m2mqtt-library/.

    When I try to build and run it, I get an error that looking as below:

    Exception thrown: ‘uPLibrary.Networking.M2Mqtt.Exceptions.MqttCommunicationException’ in M2Mqtt.NetMf.dll
    An unhandled exception of type ‘uPLibrary.Networking.M2Mqtt.Exceptions.MqttCommunicationException’ occurred in M2Mqtt.NetMf.dll

    I used lots of broker with this given codes ( CloudMQTT, HiveMQTT and my personal server…) and result is still same. Also I tried other Nuget package but still same also.

    What is your recommendation about this issue? How can I solve?
    I hope you have a lots of solution for that. Waiting for it…

    Best regards,
    Berk

  49. vishal desai says:

    Hello Sir,

    could you please help how to generate 38 Khz using STM8S003f3p

    please advise . I use arduino IDE to program it. please also advise which is more preferable software.

    Thanks
    vishal

    • Mark says:

      I personally do not use the Arduino IDE for the STM8 microcontrollers.

      However, I would look at using the PWM functionality of the Arduino libraries to see if this capability is available for your board.

      Good luck,
      Mark

  50. vishal desai says:

    Dear Sir,

    please just share me your program which is generating 320 Hz and i need 38 KHz.

    so please share the changes to be made in your program.

    Thanks for your prompt response.

    Regards
    Vishal

  51. Viktor says:

    Hello,

    Where did you find these interrupt vector numbers?
    https://blog.mark-stevens.co.uk/2012/09/interrupts-on-the-stm8s/

    Datasheet has different numbers eg.:
    ITC_IRQ_UART1_TX = (uint8_t)17, /*!< UART1 TX interrupt */
    ITC_IRQ_UART1_RX = (uint8_t)18, /*!< UART1 RX interrupt */
    ITC_IRQ_TIM4_OVF = (uint8_t)23, /*!< TIM4 update /overflow interrupt */

    Weirdly only yours work. if I use the ones from datasheet I get unhandled ISRs in IAR.

    Cheers

Leave a Reply

*