sreg register

what  register  is in gr-kaede micro-controller like sreg in avr's ?

How to use that register for programming ?

I want to use that in between interrupt and normal execution.

 

  • sreg is called PSW in RX. CCRX provides some intrinsic function to access PSW or interrupt enable bit.

    void set_psw(unsigned long data);

    unsigned lonf get_psw(void);

    void setpsw_i(void);

    void clrpsw_i(void);

    If you could explain a little more what you wat to do we might be able to propose a solution to this.

  • In reply to FrankL:

    Hi, we ported some libraries from Arduino like below code, that is using isNoInterrups(). isNoInterrupts() is defined in specific_instructions.h.

    #ifndef GRSAKURA

     uint8_t sreg = SREG; // it's Arduino

    #else

     uint8_t sreg = isNoInterrupts(); //it's SAKURA or KAEDE

    #endif

  • In reply to Okamiya Yuuki:

    unsigned char sreg = SREG;// for Arduino

    unsigned char sreg = isNoInterrupts();// for kaede

    reverse assignment.....................

    can we do this ?

    SREG = sreg;//for Arduino

    isNoInterrupts() = sreg;//for kaede

  • In reply to electron:

    I think the below code is the solution.

       bool di = isNoInterrupts();

       noInterrupts();

    -------------------------------

       execute in no interrupts

    -------------------------------

       if (!di) {

         interrupts();

       }

  • In reply to Okamiya Yuuki:

    actually I am editing the community firmware (SPRINTER) to support the gr-kaede board,

    but there are errors in compiling , 

    I can't solve these error, in line 175 MACRO and other errors also (I have added a file attachment)

    I have commented the actual MACRO definition with the end of line ........edited

    and added the same definition for kaede

    but  sir  didn't get your above solution, please give correct resolution.

    thanks 

  • In reply to electron:

    how to enable timer interrupt in kaede like in avr's there is TIMSK |= (1<<OCIE1A) ?

  • In reply to electron:

    You should modify as below about line 175 MACRO.

    #define CRITICAL_SECTION_END    if (!_sreg) {interrupts();}

    About timer, you can refer the MsTimer2 in Kaede lib. For example, you can find the code like below.

       // Start the timer.

       TPUA.TSTR.BIT.CST1 = 1U;

  • In reply to Okamiya Yuuki:

    thank you sir,

    that solved an error.

    I have another error in line 3080 and 3088 about type casting, the two dimensional array "speed_lookuptable_fast [ ] [ ]  " is taken from the another file(attached).

    and in line number 3114 , there is not defined OCR1A so, can we use " TPU1.TGRA = tcnt2 - 1" instead from the MsTimer2.h to set the time period of timer2 ?

    is there any other file like MsTimer2.h ,because  I need two timers for programming ?

    and what about ISR routine in line 3121 (it's an error) , there is also an ISR routine in MsTimer2.h ,can I replace these two? 

  • In reply to electron:

    waiting for an answer, sir .

  • In reply to electron:

    >I have another error in line 3080 and 3088 about type casting, the two dimensional array "speed_lookuptable_fast [ ] [ ]  " is taken >from the another file(attached).

    I don't have an error in line 3080 and 3088.

    What kind of error do you have?

    >and in line number 3114 , there is not defined OCR1A so, can we use " TPU1.TGRA = tcnt2 - 1" instead from the MsTimer2.h to set >the time period of timer2 ?

    >is there any other file like MsTimer2.h ,because  I need two timers for programming ?

    >and what about ISR routine in line 3121 (it's an error) , there is also an ISR routine in MsTimer2.h ,can I replace these two?

    Of course, GR-KAEDE has a lot of timer resources. I cannot implement without below header file described in sprinter_main.cpp.

    OCR1A is the native special function register in AVR used by Arduino. So you need to replace that to RX64M's one. Also ISR is native code for AVR used by Arduino.

    I can consider if you give me the header file below, but it seems to take some more time to fix an error.

    #include "fastio.h"

    #include "Configuration.h"

    #include "pins.h"

    #include "Sprinter.h"

    #include "heater.h"

  • In reply to Okamiya Yuuki:

    Here is the link for all files needed in ZIP format.

    https://drive.google.com/file/d/0B5259NIO44_UNFlEUTRMQTBHZlk/view?usp=sharing

  • In reply to Okamiya Yuuki:

    I have these errors in line 3088 and 3080, in the file sprinter_main.cpp

    ____________________________________________________________________________________

    sprinter_main.cpp: In function 'short unsigned int calc_timer(short unsigned int)':

    sprinter_main.cpp:3079:108: error: cast from 'const uint16_t* {aka const short unsigned int*}' to 'short unsigned int' loses precision [-fpermissive]

    unsigned short table_address = (unsigned short)&speed_lookuptable_fast[(unsigned char)(step_rate>>8)][0];

    ^

    In file included from sprinter_main.cpp:148:0:

    ./gr_common/core/avr/pgmspace.h:49:69: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

    #define pgm_read_word(address_short) (*(short int*)(address_short))

    ^

    ./gr_common/core/avr/pgmspace.h:50:41: note: in expansion of macro 'pgm_read_word'

    #define pgm_read_word_near(x) pgm_read_word(x)

    ^

    sprinter_main.cpp:3083:29: note: in expansion of macro 'pgm_read_word_near'

    timer = (unsigned short)pgm_read_word_near(table_address) - timer;

    ^

    sprinter_main.cpp:3087:80: error: cast from 'const uint16_t* {aka const short unsigned int*}' to 'short unsigned int' loses precision [-fpermissive]

    unsigned short table_address = (unsigned short)&speed_lookuptable_slow[0][0];

    ^

  • In reply to electron:

    I tried to look your sources and original sources in github.

    I think it's hard to implement how to work actual Sprinter. For example, the original source use the TIMER1 interrupt as below function.

    ISR(TIMER1_COMPA_vect)

    I mean even if you remove errors in compiler, Splinter seems not to operate. And when it does not work, I do not solve the problem. Because I don't have  the hardware.

     

    If you progress to port from native Arduino code such as TIMER1 to GR-KAEDE, I recommend to use e2studio, that is local environment.

     You can download e2studio from below site. 

    http://www.renesas.eu/products/tools/ide/ide_e2studio/downloads.jsp#

    And you can download the project files(zip) from below. Please import zip to e2studio as archive.

     http://renesasrulz.com/gadget_renesas_user_forum/m/mediagallery/2692.aspx