@ted, what makes you think these globals deserve parentheses, and the others don't?
I'm genuinely curious about your thought processes, and concepts of syntax.
These symbols are not part of Arduino:
PA0, PA1, PA2, PA3, PA4, PA5
PB13, PB15, PC14
Some of them are contained in the i/o header files that come with the avr-gcc package but which ones vary depending on which AVR processor the code is being built for.
But none of them are part of Arduino.
I'm not sure what you think they are but I'm fairly sure that they are not what you think they are.
What do you think those are?
What Arduino board and processor core are you using?
This is not a problem with the name of the pins,they are from stm32, is the line mentioned correctly written?
The LEDs on pinss PB13and pb15 are working properly.
OK so those symbols are pin names from the stm32 core.
Definitely not portable and not part of Arduino but ok they represent pin numbers when using the stm32 core.
Given that, this line makes no sense:
if (PB13 == 1 && PB15 == 1)
As PB13 and PB15 would be constants and are either 1 or some other number and it is very likely that PB13 and PB15 are not both pin 1, so that expression inside the if would evaluate to false which means that the compiler would through away everything inside the true part of the if statement and would keep the else side of the if statement.
Which means that this:
if (PB13 == 1 && PB15 == 1)
{
digitalWrite(PC14, HIGH);
LED = 1;
}
else
{
digitalWrite(PC14, LOW);
LED = 0;
}
Is the same as if the code were written this way:
digitalWrite(PC14, LOW);
LED = 0;
Since the if expression will always evaluate as false and only the else code will be executed.
So again I ask what do you think those symbols are/represent/do?
ted:
The symbols
The firstline = arduino pins names.
The second = stm32 pin names.
Nope.
The first line of symbol names (PA0 to PA7) are not Arduino pin names.
Arduino uses A0, A1, A2, A3 ....
and in newer IDE releases it also provides PIN_A0, PIN_A1, etc... symbol names.
PA0, PA1, PA2, PA3, PA4, PA5, PA6, PA7 are register bit number symbols in AVR processor specific system header files that are part of avr-gcc tools but those names are not part of Arduino.
They are defined to be 0, 1, 2, 3, 4, 5, 6, 7
i.e. they are available when compiling Arduino sketch or library code for AVR processors but they are not part of Arduino.
Just like h/w symbols like DDRA, PORTB, PORTB5, and a slew of many other h/w symbols.
They can be used when building Arduino code for an AVR processor but they are not part of Arduino.
It is a bit unfortunate that only the stm32 specific pin symbol names are printed on the PCB rather than also showing the Arduino digital pin numbers.
Some boards like Teensy print both. The AVR/teensy specific symbol names on one side and the Arduino pin numbers on the other.
I also went and looked at the stm32 variant files and they are also not declaring the Arduino An symbols for the analog channels.
i.e. A0, A1, A1 etc....
Many of the arduino programs are working with stm32, just by renaming the pin names, but set the timers is different.
Can you help me with that ?
This are two codes,one for arduino the second one for stm32.
Please fill the lines with question mark if you can.
// Set up timer 1.
// Prescaler = 1, phase correct PWM mode, TOP = ICR1A //phase correct PWM mode
TCCR1A = (1 << COM1A1) | (1 << WGM11); // ?
TCCR1B = (1 << WGM12) | (1 << WGM13) | (1 << CS10); // CTC mode, prescaler = 1,
// What does it mean CTC mode ?
TCCR1C = 0; // Timer/Counter Control Register A, / 0 = ?
OCR1AH = (TIMER1_TOP / 2 >> 8); // Output Compare Register A High / Output Compare Register A High ?
OCR1AL = (TIMER1_TOP / 2 & 0xFF); // Output Compare Register A Low / TOP/2 & 0xFF = ?
ICR1H = (TIMER1_TOP >> 8); // Output Compare Register B High / TOP & 0xFF ?
ICR1L = (TIMER1_TOP & 0xFF); // Output Compare Register B Low / TOP & 0xFF ?
TCNT1H = 0; // Timer/Counter Register High (The Timer - High) / 0 = ?
TCNT1L = 0; // Timer/Counter Register Low (The Timer - Low) / 0 = ?
TIFR1 = 0x07; // clear any pending interrupt = refresh ? / 0 = ?
TIMSK1 = (1 << TOIE1); // = resume ?
STM32F103
HardwareTimer pwmtimer3(3); //timer #3
void setup() {
pinMode(PA7, PWM);
pinMode(PB0, PWM);
pwmtimer3.pause();
pwmtimer3.setPrescaleFactor(1); // Timer input clock Prescaler = 1
pwmtimer3.setOverflow(100-1); // PWM Period width for 720kHz
pwmtimer3.setCompare(TIMER_CH3, 50); // CH#3 -PWM High Pulse width is 50% duty (1:1)
pwmtimer3.setCompare(TIMER_CH2, 50); // PWMCH#2 High Pulse width is 50% duty (1:1)
pwmtimer3.refresh();
pwmtimer3.resume();