Comments (8)
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.
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.
But thanks a lot for the hint with Timer 0. I would have never thought about that. :)
from ch55xduino.
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.
Those existing isr handlers are for External int 0 and 1, and timer 0
from ch55xduino.
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.
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.
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)
- CH554 support HOT 12
- About usb sample code
- Idea: add TinyRF capability to open the ch55x to 315/433MHz communication HOT 3
- Keyboard with boot protocol enabled HOT 8
- About absolute mouse HOT 2
- Drivers problem HOT 3
- TouchKey_begin disrupts functionality of pins not enabled for touch HOT 2
- CH55X ARDUINO CORE
- [Demo] Ch554 USB Audio Speaker HOT 5
- Feature request: InfraRed Encoder/Decoder.
- Support more than 85 LEDs (256 bytes RGB Data) for WS2812 HOT 2
- CH546L unresponsive after flash HOT 5
- Can you add an example about ch559 USB host? This is a very important feature thx HOT 2
- CH552 into sleep mode and wake it up or switch to low power HOT 1
- Softreset after download CH549 HOT 4
- CH558L unresponsive after first flash HOT 7
- WS2812 Brightness HOT 3
- Timer3 Interrupts on the CH558 not working (with suggested fix) HOT 1
- Keyboard Matrix Problem HOT 2
- keyboard_getLEDStatus() does not respond to a NUM LOCK, CAPS LOCK or SCROLL LOCK change HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ch55xduino.