Comments (10)
Is it possible to operate ‘Fast mode’ through ‘CORE1’?
Hi
You can easily write such "fast mode" itself, using the direct port manipulation:
int pin = PA5;
// generate a port and mask for defined pin
uint32_t* pin_set_register = portSetRegister(pin);
uint32_t pin_set_mask = digitalPinToBitMask(pin);
// set pin HIGH ( as digitalWrite() HIGH)
*pin_set_register = pin_set_mask;
// set pin LOW (digitalWrite() LOW)
*pin_set_register = pin_set_mask << 16;
from arduino_stm32.
Thank you.
I understand how to do it.
Is there a method using 'digitalRead'?
from arduino_stm32.
I think that the syntax seems to be the similar, but I never need a "fast" digitalRead() in my projects.
from arduino_stm32.
use:
uint16_t value = *portInputRegister(pin) & digitalPinToBitMask(pin);
if value == 0 then pin is "low", otherwise pin is "high".
from arduino_stm32.
@stevstrong
Thank you for answer.
However, I'm saying this because I don't know much, but 'an error occurs during compilation'.
code :
int pin7 = PA5;
uint16_t value1 = *portInputRegister(pin7)& digitalPinToBitMask(pin7);
error :
\generic_stm32f103c/variant.h:7:44: error: base operand of '->' is not a pointer
#define portInputRegister(port) ( &(port->regs->IDR) )
from arduino_stm32.
then try:
uint16_t value1 = portInputRegister(pin7) & digitalPinToBitMask(pin7);
from arduino_stm32.
code :
uint16_t value1 = *portInputRegister(digitalPinToPort(pin7)) & digitalPinToBitMask(pin7);
Thank you.
from arduino_stm32.
It doesn't work.
code:
const int SIG[] = {PA5, PA4, PA0, PA15};
//------------------------------------------------ --------------------//
value1 = *portInputRegister(digitalPinToPort(SIG[0])) & digitalPinToBitMask(SIG[0]);
value2 = *portInputRegister(digitalPinToPort(SIG[1])) & digitalPinToBitMask(SIG[1]);
value3 = *portInputRegister(digitalPinToPort(SIG[2])) & digitalPinToBitMask(SIG[2]);
uint16_t hall_y = 0; uint16_t hall_b = 0; uint16_t hall_g = 0;
if(value1==0){ hall_y = 0; }else{ hall_y = 1; }
if(value2==0){ hall_b = 0; }else{ hall_b = 1; }
if(value3==0){ hall_g = 0; }else{ hall_g = 1; }
//------------------------------------------------ --------------------//
from arduino_stm32.
What exactly do you mean "it doesn't work"? Which part does not work?
from arduino_stm32.
It doesn't work.
@SeongJongKwak
The port access syntax is correct, the error somewhere else in your code.
from arduino_stm32.
Related Issues (20)
- How can I make 'STM32F103C8T6' DIY? help me. HOT 3
- USB Serial echos characters into the input (i.e. keyboard) HOT 15
- Support for Arduino IDE 2.х HOT 7
- PIN_MAP and boardPWMpins tables mismatch HOT 1
- Arduino IDE "Access Denied" on Uploading Sketch HOT 3
- Can't connect to target after flashing generic_boot20_pc13.bin using j-flash HOT 1
- Software reset HOT 1
- How to change default 42/72/128 MHz to 8/16Mhz HOT 2
- Add CH32F103 HOT 2
- Compilation error Problem with sketch that used library Arduino_STM32 HOT 1
- dfu upload failed on macOS + PlatformIO because cannot reset upload port HOT 5
- Writing String to EEPROM HOT 3
- EEPROM donot work on STM32F103C6(32k)
- ‘MCU basic current’ increases after PWM operation. help me. HOT 25
- Wire.h and Wire slave.h using in same program not working HOT 2
- Is any type a persistent storage available for STM32F4 ?
- Solution to use PB3 for things other than JTAG (Proposal for documentation note) HOT 2
- Not able to uploaded the code for NUCLEO-F103R HOT 2
- change clock soure HOT 5
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 arduino_stm32.