Comments (8)
You don't need to stop interrupts if you are in one. cli/sei aren't a single instruction but they are probably better to be __disable_irq
/ __enable_irq
.
You would need to show me more code if you are struggling to get info on how to improve your interrupt code.
from ch32v003fun.
PD3 with rising edge trigger used in pin change example code;
// Configure the IO as an interrupt.
AFIO->EXTICR = 3<<(3*2); //PORTD.3 (3 out front says PORTD, 3 in back says 3)
EXTI->INTENR = 1<<3; // Enable EXT3
EXTI->RTENR = 1<<3; // Rising edge trigger
// enable interrupt
NVIC_EnableIRQ( EXTI7_0_IRQn );
I'm try to write both rising and falling trigger for pc1.
AFIO->EXTICR = 2<<(1*2);
EXTI->INTENR = 1<<3;
EXTI->RTENR = 1<<3;
EXTI->FTENR = 1<<3;
Is it correct?
EDIT: It's wrong.
AFIO->EXTICR = 2<<(1*2); // PC1: PortC = 2, << Pin1 = 1 * 2
EXTI->INTENR = 1<<(1); // EXT1 Enable
EXTI->RTENR = 1<<(1); // EXT1 Rising edge trigger
EXTI->FTENR = 1<<(1); // EXT1 Falling edge trigger
It worked now.
from ch32v003fun.
I believe that is also correct, generally.
from ch32v003fun.
I made a little progress. https://github.com/phantomxe/ch32v003_ow/tree/main/ow_probe_adc
Also combined with ADC DMA example. But i got some triggering problems at reset state. Is it possible to check my code in terms of interrupt usage or general structure? @cnlohr
from ch32v003fun.
I am not quite sure what I should be searching for.
One thing makes me anxious is the EXTI7_0_IRQHandler
interrupt - You should probably use a state machine, either with a switch
statement or a function pointer to the current state, It will prevent a lot of branches. Branches on the CH32V003 are expensive.
from ch32v003fun.
I am still interested in seeing this come to fruition. Any chance you would still get it further over the finish line?
from ch32v003fun.
I apologize in advance for hijacking this thread with potentially irrelevant information, but if I remember it correctly it is not possible to emulate the 1-wire protocol in a slave device unless you have a proper Maxim/Dallas license (or use genuine Maxim/Dallas part). Unfortunately, I could not find the original document with the information, only informal mentions on the internet. IANAL so it might be fine to use 1-wire slave device emulation for e.g. educational purposes, but if you plan to use it commercially, I would recommend checking with the company legal department.
Sorry again and thank you for your understanding.
from ch32v003fun.
@cw2 Thanks for your attention. I just on the educational zone.
@cnlohr I used to think that I had a knowledge about development on embedded systems. But after i started with experimenting on ch32v003fun, i found my knowledge is mediocre. After several weeks of development with logic analyzer, It worked partially. It can sense the reset and respond with presence pulse, read-write operations are possible. I want to combine with adc dma example. I tried to send ADC data over scratchpad but it's not working.
//so I'm not going to do temperature conversion at now
scratchpad[0] = (uint8_t)(adc_buffer[0] & 0xFF); // FIXME not working
scratchpad[1] = (uint8_t)((adc_buffer[0] >> 8) & 0xFF);
scratchpad[2] = 0x31; // for debugging
And i refactored if-else statements to switch-case. You can have a look at my latest code in the repository. But I don't understand that why i can't run any printf, adc on main loop when onewire stuff is working on interrupt. Sorry for the inconvenience.
from ch32v003fun.
Related Issues (20)
- Wrong definition of funPinMode? HOT 2
- FUN_HIGH and FUN_LOW behave reversed for funDigitalWrite HOT 1
- Convoluted UART_BRR calculation HOT 3
- Redundant `blink[_raw].bin` files source controlled in repo? HOT 11
- TODO For new updates
- Configurable RAM sizes for V20x, V30x HOT 8
- Compilation results in no code HOT 1
- Make minichlink print flash amount HOT 1
- Make semihosting printf speed along if it times out.
- Empty LD file on missing build tools HOT 2
- prebuilt blink.bin example doesn't seem to work on a CH32V003 board HOT 1
- PWM 8 KHz 16 bit HOT 11
- Onewire slave
- CH32V003A4M6 SPI? HOT 2
- Is this board right for me? HOT 5
- Are there defined symbolic constants for AFIO_EXTICR register values? HOT 5
- minichlink not detecting esp32 programmer on MacOS. HOT 1
- DISCUSSION - Could this run Klipper ? I think it really could omg HOT 8
- Why does my code stop when I connect minichlink terminal? HOT 8
- v30x blink example don't run if TARGET_MCU_PACKAGE sets to CH32V307VCT6 HOT 6
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 ch32v003fun.