STM32F4 RTC not shadow regidter not updating

December 23, 2015

Had a problem where the time is not being updated in the shadow register even after calling HAL_RTC_WaitForSynchro()

Apparently I’ve missed this in the function header:

  * @brief  Gets RTC current time.
  * @param  hrtc: pointer to a RTC_HandleTypeDef structure that contains
  *                the configuration information for RTC.
  * @param  sTime: Pointer to Time structure
  * @param  Format: Specifies the format of the entered parameters.
  *          This parameter can be one of the following values:
  *            @arg RTC_FORMAT_BIN: Binary data format 
  *            @arg RTC_FORMAT_BCD: BCD data format
  * @note You must call HAL_RTC_GetDate() after HAL_RTC_GetTime() to unlock the values 
  * in the higher-order calendar shadow registers to ensure consistency between the time and date values.
  * Reading RTC current time locks the values in calendar shadow registers until Current date is read.
  * @retval HAL status

Motorola XT701 – Too Slow

February 23, 2012

My Motorola XT701 Android phone is aging and it performance is not as smooth as it use to be.

The problem annoy me for long time but the option of wiping it fresh was not very appealing, until “enough is enough” and I’ve decided to do that! but before I do I remind myself with the steps to get into system recovery.

  1. Turn the phone Off.
  2. power it up by continually holding the power button and the media button (the small button next to the camera button). Hold both until you get a screen with /!\.
  3. then push the volume-up button and the camera button to get the system recovery menu:

    reboot system
    wipe data/factory reset
    wipe cache partition
  4. Use the volume button to change selection and the camera button to apply.

Choosing the third option you will clear all the phone setting installations and data and return it to the factory settings: the state it was when it was new, a very costly operation.  but apparently choosing the forth option will not harm or change the phone at the user level at all.

Before selecting the third option I tried the forth. It work! the phone operation is now smooth and fast and it seems like it was rejuvenated.

Migrating from POP3 to IMAP

January 30, 2012

For long time I had a POP3 account as my primary email and manage to accumulate a reasonable number of messages that I’d like to keep. POP3 is great, you can create and read emails locally on your PC. you can backup the messages as they take the form of files locally. Well it great as long as you have one primary PC. one I got really busy and got smart-phone i thought it would be grate to be able to read emails on the go and at work.

The solution is obviously IMAP. To be fair had i know what is IMAP I would have use it from start. The problem now is that all my old messages are locally stored on my home PC in folders and sub-folders and I want to be able to browse them in my new account, which is the same account using IMAP.

I needed to put the old messages back to the server. The trivial way is to send them all to self but that means loosing the sender name. I needed a tool that push back the old messages. I couldn’t find any tool that do that. Loosing easy access to all my old messages would be a deal breaker for me.

The solution is very simple, I am using MS live client and to push messages to the server all you need is to drag them into the IMAP folder and the client will simply do that.

Probably the reason I couldn’t find any tool is that it a trivial task. The down side is that you can’t drag folders, just messages.

SlickEdit autogenerated Makefile configuration

February 3, 2010

SlickEdit autogenerated Makefile generate the following by default.

# SlickEdit generated file.  Do not edit this file except in designated areas.

# Make command to use for dependencies

# -----Begin user-editable area-----

# -----End user-editable area-----

# If no configuration is specified, "Debug" will be used
ifndef CFG

But what if you want to use another make application?
you need to do it in the Makefile itself:

# -----Begin user-editable area-----
# -----End user-editable area-----

Simple UTF-8 C Decoder

December 23, 2008

This is a simple C or C++ code for UTF-8 decoder

// given that this is first byte of the character,
// how many bytes is the character occupy?
int NumberOfUTF8Chars(unsigned char ch)
if (ch < 0x80u) return 1; else if (ch < 0xE0u) return 2; else if (ch < 0xF0u) return 3; else if (ch < 0xF8u) return 4; else if (ch < 0xFCu) return 5; else return 6; } // given that this is first byte of the character, // what is the code value of that character? unsigned int ValueOfUTF8Code(const char* ch) { unsigned int Value; int Size = NumberOfUTF8Chars( *ch ); switch( Size ) { case 6: Value = ch[0] & 0x01; break; case 5: Value = ch[0] & 0x03; break; case 4: Value = ch[0] & 0x07; break; case 3: Value = ch[0] & 0x0F; break; case 2: Value = ch[0] & 0x1F; break; case 1: Value = ch[0]; } for ( int i= 1; i < Size; i++ ) { Value = Value << 6 | ch[i] & 0x3F; } return Value; } [/sourcecode] This code was never actually tested. Use it on your own risk.

LM058 communication problem

December 5, 2008

It should not escalated to this level and since it does it a bad evidence on the ‘LM Technologies’ brand.

I am working on a system the include communication from a smartphone to a controller.
The controller support RS232, the smartphone support Bluetooth and to bridge this gap I purchased a ‘Bluetooth Serial adaptor’ from ‘LM Technologies’.

The connection works well until the device sends a string longer than 20-40 characters. Then the LM058 freezes and never recovers. (power cycle require)

I tried all known configurations, I sent question to LM support (there website support is terrible), I posted a question in related forums (and in an unrelated forums :).

At this stage it become apparent that either my device is faulty or just badly designed.

A week after my initial question to LM support I got response that suggested disabling the ‘escape character check’ using the AT command ‘ATX0‘. That indeed solve the problem.

Why is this feature not documented in the LM058 user manual?? or any other related LM058 documents!!??

In the purpose of this blog I am adding a link to another adaptor manual that actually describe this feature. It seems that LM updated the LM058 adaptor functionality but not the manuals.

here it is: a little piece of information that was not part of the ‘world accumulated knowledge base’ (Internet) and now it is.
In the future I’ll try to be more informative and ‘to the point’ and less ‘blah blah’.

RIM JDE debug messages

November 25, 2008

Maybe it my fault that I didn’t read the whole of RIM’s documentation or maybe it just not there.

Anyway I was looking for a while for how to print debug messages in the JDE’s debug window and now I found it.
Simply use the system output stream:
System.out.println( "message " + number );