Giter Club home page Giter Club logo

n76e003's Introduction

N76E003

This project aim to support the Nuvoton N76E003 microcontroller in Linux/Windows (Cygwin)
using SDCC.

Problem with bitwise OR and SFRs (Thanks to Skcks)

NOTE: This issue occurs only in sdcc versions 3.8 and below.

When sdcc compiles the instruction "=|" (bitwise inclusive OR and assignment)
it uses 3 instructions, and for some protected SFR's only 4 cycles could take
place after the TA protection unlock is called.

Example:

Keil C51 code:
--------------

mov	TA, #0xAA				; TA = 0xAA  
mov	TA, #0x55				; TA = 0x55 {'U'}  
orl	SFRS, #0x01		  	; SFRS |= 0x01  

SDCC non corrected code:
--------------------------

mov	TA, #0xAA			   ; TA = 0xAA  
mov	TA, #0x55			   ; TA = 0x55 {'U'}  
mov	R6, SFRS				; R6 = SFRS  
orl	0x06, #0x01			 ; 0x06 |= 0x01  
mov	SFRS, R6				; SFRS = R6  

Solution 1

Use a peep.def file containing:

replace {
  mov  %1,%2
  orl  a%1,%3
  mov  %2,%1
} by {
  orl  %2,%3
}

Solution 2 (Thanks to Vladimir Shevtsov / MrFeek)

Make a modified SFR_Macro.h replacing all "|=" statments

Example:

Replace this:  #define  set_SMOD    PCON |= SET_BIT7; // Original
By this:             #define  set_SMOD   _asm_ ("orl _PCON,#0x80");  // SDCC compatible

Disable Power-On Reset (POR)

Nuvoton (strongly) recommends disable POR at startup. See section 24.1 of
the datasheet for more information. That could be done using the
"_sdcc_external_startup" function as shown below.

unsigned char _sdcc_external_startup (void)  
{  
    __asm  
    mov	0xC7, #0xAA  
    mov	0xC7, #0x55  
    mov	0xFD, #0x5A  
    mov	0xC7, #0xAA  
    mov	0xC7, #0x55  
    mov	0xFD, #0xA5  
    __endasm;  
    return 0;  
}  

n76e003's People

Contributors

wkaster avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.