Search found 62 matches

by C_D
Thu Oct 05, 2017 8:39 pm
Forum: Code snipplets
Topic: A faster ringbuffer implementation
Replies: 12
Views: 1839

Re: A faster ringbuffer implementation

You are already checking to see if the buffer is full to decide if you need to throw out an element. Instead, you could always use a size of 16 for the ringbuffer and then check for an available() count of 8 instead of the the buffer.capacity(). That would allow you to use a shift divide. However, ...
by C_D
Wed Oct 04, 2017 11:54 pm
Forum: Code snipplets
Topic: A faster ringbuffer implementation
Replies: 12
Views: 1839

Re: A faster ringbuffer implementation

You just need to provide the POP_T data type and make it the same as the T data type. I used this "feature" to my advantage using uint8_t as the data type but returning a int16_t with an empty value of -1. Aha, I knew there had to be a reason for it, I just couldn't think of any reason why the retu...
by C_D
Wed Oct 04, 2017 2:26 am
Forum: Code snipplets
Topic: A faster ringbuffer implementation
Replies: 12
Views: 1839

Re: A faster ringbuffer implementation

Just came back to my project using these neat ringbuffers, and found theres a bit of bug in the posted code. typename POP_T = int16_t, /* return type of pop_front */ ... // affects tail, reads head POP_T pop_front(void) { register uint16x2_t temp = { offsets.both }; if ( (temp.head - temp.tail) & CA...
by C_D
Mon Sep 11, 2017 1:52 am
Forum: STM32F103 Boards
Topic: [SOLVED] HardwareSerial stm32f103 pin remapping
Replies: 3
Views: 794

Re: HardwareSerial stm32f103 pin remapping

I just had to do the same thing but on USART3. The following worked for me: // remap USART3 afio_remap(AFIO_REMAP_USART3_PARTIAL); gpio_set_mode(GPIOC, 10, GPIO_AF_OUTPUT_PP); gpio_set_mode(GPIOC, 11, GPIO_INPUT_FLOATING); gpio_set_mode(GPIOC, 12, GPIO_AF_OUTPUT_PP); If you do not explicitly set the...
by C_D
Tue Sep 05, 2017 8:01 pm
Forum: USB bootloader
Topic: Changing PLL settings for 24Mhz XTAL
Replies: 24
Views: 547

Re: Changing the XTAL frequency

Ah yeah so I'm not actually overclocking the core am I, the internals of the MCU are all running as intended, its just the oscillator circuit thats running outside of spec. I will keep that in mind while testing these boards and make sure that future revisions have an 8MHz crystal. Victor The board ...
by C_D
Tue Sep 05, 2017 2:16 am
Forum: USB bootloader
Topic: Changing PLL settings for 24Mhz XTAL
Replies: 24
Views: 547

Re: Changing the XTAL frequency

That looks like some sort of light controller, but can't figure out what the THn pins would be other than thermistors. Correct on both counts, it has both lights and thermistors, though the lighting isn't really 'controlled' as such. It could just a easily be on a separate board but its all on one ...
by C_D
Tue Sep 05, 2017 2:12 am
Forum: USB bootloader
Topic: Changing PLL settings for 24Mhz XTAL
Replies: 24
Views: 547

Re: Changing the XTAL frequency

Yup, the 24MHz crystal was a mistake for sure. I've got a handful of boards made like this which I will keep working with now I have the bootloader running. Next version will be back to 8MHz for sure. I will look into the ST core too, I should at the very least have a play with it and see if its wor...
by C_D
Tue Sep 05, 2017 1:42 am
Forum: USB bootloader
Topic: Changing PLL settings for 24Mhz XTAL
Replies: 24
Views: 547

Re: Changing the XTAL frequency

Fear not, its a prototype only :lol: And no it wont kill anyone if it catches fire. But the Arduino environment is perfect for me to quickly mash out new features to play with and test. I actually arrived here having come from MBed and the Nucleo range because a few years ago the USB serial implemen...
by C_D
Tue Sep 05, 2017 1:19 am
Forum: USB bootloader
Topic: Changing PLL settings for 24Mhz XTAL
Replies: 24
Views: 547

Re: Changing the XTAL frequency

And confirmed working 8-)

Thanks so much guys. Sorry to have taken up your time with a silly mistake, but on the plus side I know a heap more about what makes Arduino for STM32 work now!
by C_D
Tue Sep 05, 2017 1:04 am
Forum: USB bootloader
Topic: Changing PLL settings for 24Mhz XTAL
Replies: 24
Views: 547

Re: Changing the XTAL frequency

victor_pv wrote:
Tue Sep 05, 2017 12:42 am
This is wrong ...
This should work (multiplies by 3):

Code: Select all

   SET_REG(RCC_CFGR, GET_REG(RCC_CFGR) | 0x00050400); /* pll=72Mhz(x3),APB1=36Mhz,AHB=72Mhz */
RogerClark wrote:
Tue Sep 05, 2017 12:50 am
His bit pattern was wrong.
:oops:
I am embarrassed to say I double checked that and still got it wrong.