diff --git a/esp8266/modpybrtc.c b/esp8266/modpybrtc.c
index c0331760c6e054a6cf87bd02230cacf00374724d..7bf65e821c196256a11060a2cbe4d59112061c7a 100644
--- a/esp8266/modpybrtc.c
+++ b/esp8266/modpybrtc.c
@@ -47,7 +47,7 @@ typedef struct _pyb_rtc_obj_t {
 #define MEM_USER_MAXLEN     (512 - (MEM_USER_DATA_ADDR - MEM_DELTA_ADDR) * 4)
 
 STATIC uint64_t pyb_rtc_raw_us(uint64_t cal) {
-    return system_get_rtc_time() * ((cal >> 12) * 1000 + (cal & 0x0) / 4) / 1000;
+    return system_get_rtc_time() * ((cal >> 12) * 1000 + (cal & 0xfff) / 4) / 1000;
 };
 
 void pyb_rtc_set_us_since_2000(uint64_t nowus) {