Git Product home page Git Product logo

Comments (8)

DeqingSun avatar DeqingSun commented on June 9, 2024

If you check wiring.c you will see the timer0 is reserved for millis and micros function for timing. This is a common practice for Arduino. You can use T2, or T1 if you don't use the uart module.
If you want to use interrupt. You need to add handler both in your code and main.c.

And using direct register acesss is generally not recommended for Arduino, unless the library can not do what you want.

from ch55xduino.

Vykynger avatar Vykynger commented on June 9, 2024

Actually, it seems like I am configuring the Timers wrong because Timer 1 and external Interrupt 1 are not working either. Unfortunately, I did not find any example of a CH55x Timer implementation using the Arduino IDE. Do you know where to find a working example? Also, I did not quite understand the #pragma NOOVERLAY thing because the Arduino IDE does not seem to recognise it.

from ch55xduino.

Vykynger avatar Vykynger commented on June 9, 2024

But thanks a lot for the hint with Timer 0. I would have never thought about that. :)

from ch55xduino.

Vykynger avatar Vykynger commented on June 9, 2024

Regarding If you want to use interrupt. You need to add handler both in your code and main.c. :
I finally found the main.c file in /home/username/.arduino15/packages/CH55xDuino/hardware/mcs51/0.0.9/cores/ch55xduino
So thanks a lot! :) Now I only have to find out, how to setup the ext. Interrupt 1. In the main.c file there are both external interrupts already occupied with void INT1_ISR(void) __interrupt (INT_NO_INT1) { intFunc[1](); }
So how do I add my own External interrupt?
Regarding And using direct register access is generally not recommended for Arduino unless the library can not do what you want :
How can I configure the timers then? Do you mean for example using: IE = 0; IE |= (1<<EA); instead of EA = 1? I am not that proficient in C.

from ch55xduino.

DeqingSun avatar DeqingSun commented on June 9, 2024

Those existing isr handlers are for External int 0 and 1, and timer 0

from ch55xduino.

Vykynger avatar Vykynger commented on June 9, 2024

Ok thanks for that fast answer. But how do I set up an external Interrupt then? What ist intFunc[1]? Again writing an normal ISR that handles te external interrupt in the Arduino file does not seem to work. Also naming the ISR in the Arduino Code INT1_ISR(void) does not work either. Can you maybe just give me an example or tell me a little bit detailed on how to use the Ext. Interrupt with the Arduino IDE?
Below this there is an example that I would like to get to run using the Arduino IDE.:

#include <ch554.h>
#include <debug.h>


#define LED_PIN 7
SBIT(LED, 0x90, LED_PIN);
void main() {
    CfgFsys();
    P1_DIR_PU &= 0x0C;
    P1_MOD_OC = P1_MOD_OC & ~(1<<LED_PIN);
    P1_DIR_PU = P1_DIR_PU |	(1<<LED_PIN);

      // Initialisierung
   IT1 = 1;    // Falling-Edge Trigger for Ext. Interrupt 1
   EX1 = 1;    // External Inteerupt 1 aktivieren
   EA  = 1;    // Globalen Interrupt aktivieren
   while (1) 
   {
   }
}
void Ext(void) __interrupt (INT_NO_INT1)
{
        LED = !LED;
}

from ch55xduino.

DeqingSun avatar DeqingSun commented on June 9, 2024

Check https://github.com/Blinkinlabs/ch554_sdcc/blob/3b86045fbefc1ff38484acbfa4289cf923451033/include/ch554.h#L695 for info about adding additional ISR in main.c. That will give you a hint about how to add another ISR.

Back to you external ISR request, check https://github.com/DeqingSun/ch55xduino/blob/ch55xduino/ch55xduino/ch55x/libraries/Generic_Examples/examples/02.Digital/AttachInterrupts/AttachInterrupts.ino

If you have never played with any Arduino board, try the examples to understand how the Arduino works.

from ch55xduino.

Vykynger avatar Vykynger commented on June 9, 2024

Thank you very very much for your help! I had not found this example library yet. But with it is really easy to program a wch552 with the Arduino IDE. :)

from ch55xduino.

Related Issues (20)

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.