Jump to content

atomsoft

Members
  • Content Count

    15
  • Joined

  • Last visited

  • Days Won

    1

Reputation Activity

  1. Like
    atomsoft got a reaction from bluehash in STM32F4-Discovery Control for GRBL   
    More info will be posted here. Its basically a control for a cnc machine using GRBL as the controller.
     
    http://www.shapeoko....70&p=2960#p2960
  2. Like
    atomsoft got a reaction from bluehash in GPIO - STM32F4   
    /********************************************************************** GPIO Mode Register - GPIOx->MODER 00 = INPUT 01 = OUTPUT 10 = ALTERNATE FUNCTION 11 = ANALOG Example: Make LED pin output **********************************************************************/ #define LED 3 GPIOx->MODER |= (1 << (LED * 2)); //Set to Output /********************************************************************** GPIO Type Register - GPIOx->OTYPER 0 = PUSH-PULL (default) 1 = Open Drain Example: Make LED pin push-pull type **********************************************************************/ #define LED 3 GPIOx->OTYPER &= !(1 << LED); //Set to Push-Pull /********************************************************************** GPIO Output Speed Register - GPIOx->OSPEEDR 00 = 2MHz (Low Speed) 01 = 25MHz (Med. Speed) 10 = 50MHz (Fast Speed) 11 = 100MHz/80MHz (High Speed)(100MHz(30pf) - 80MHz(15pf)) Example: Make LED pin 100MHz **********************************************************************/ #define LED 3 GPIOx->OSPEEDR |= (0x02 << (LED * 2)); //Set Max of 50MHz Speed /********************************************************************** GPIO Pull-Up / Pull-Down Register - GPIOx->PUPDR 00 = No Pull-Up / No Pull-Down 01 = Pull-Up Enabled 10 = Pull-Down Enabled 11 = Reserved Example: LED pin with NO PU/PD **********************************************************************/ #define LED 3 GPIOx->PUPDR |= (0x03 << (LED * 2)); //Set it for NO PUPD /********************************************************************** GPIO Input Data Register - GPIOx->IDR Read Pin State Example: Get input from button **********************************************************************/ #define BTN 2 variable = ((GPIOx->IDR >> BTN) & 1); //Get Button State /********************************************************************** GPIO Output Data Register - GPIOx->ODR Write Pin State Example: Turn on LED **********************************************************************/ #define LED 3 GPIOx->ODR |= (1<<LED); //Turn on LED /********************************************************************** GPIO Bit Set/Reset Register - GPIOx->BSRRn n = H (RESET) n = L (SET) Set or Reset Pins Example: Turn LED On then Off **********************************************************************/ #define LED 3 GPIOx->BSRRL |= (1<<LED); //Turn On LED GPIOx->BSRRH |= (1<<LED); //Turn Off LED /********************************************************************** RCC AHB1 peripheral clock register (RCC_AHB1ENR)(5.3.10 in REF MAN) BIT H = ON BIT L = OFF Example: Enable all GPIO Clocks (A:I) **********************************************************************/ #define ALL_GPIO 0x1FF RCC->AHB1ENR = ALL_GPIO;
     
    GPIO Funtion:

    void ConfigPin(GPIO_TypeDef *myGPIO, uint32_t PIN, uint32_t MODE, uint32_t SPEED, uint32_t PUPD) { /* myGPIO: The GPIOx port for the selected pin MODE: 0 = INPUT .... 1 = OUTPUT .... 2 = ALTERNATE FUNCTION .... 3 = ANALOG SPEED: 0 = 2MHz (Low Speed) .... 1 = 25MHz (Med. Speed) .... 2 = 50MHz (Fast Speed) .... 3 = 100MHz/80MHz (High Speed)(100MHz(30pf) - 80MHz(15pf)) PUPD: 0 = No Pull-Up / No Pull-Down .... 1 = Pull-Up Enabled .... 2 = Pull-Down Enabled .... 3 = Reserved */ myGPIO->MODER |= (MODE << (PIN * 2));//OUTPUT myGPIO->OSPEEDR |= (SPEED << (PIN * 2));//50MHz myGPIO->PUPDR |= (PUPD << (PIN * 2)); //Set it for NO PUPD }
  3. Like
    atomsoft got a reaction from bluehash in Turn On LED - STM32F4   
    #include <stm32f4xx.h> #define ALL_GPIO 0x1FF #define LED 15 void main(void) { RCC->AHB1ENR = ALL_GPIO; GPIOD->MODER |= (1 << (LED * 2));//OUTPUT GPIOD->OSPEEDR |= (0x02 << (LED * 2));//50MHz GPIOD->PUPDR &= (0x03 << (LED * 2)); //Set it for NO PUPD GPIOD->BSRRL |= (1<<LED); while(1) { } }
  4. Like
    atomsoft got a reaction from bluehash in Config USART2 - STM32F4   
    void ConfigUSART2(uint32_t BAUD, uint32_t apbclock) { uint32_t tmpreg = 0x00; uint32_t integerdivider = 0x00; uint32_t fractionaldivider = 0x00; RCC->APB1ENR = (1 << 17); //Enable USART2 Clock GPIOD->MODER |= (2 << 10); //Setup TX pin for Alternate Function GPIOD->MODER |= (2 << 12); //Setup RX pin for Alternate Function GPIOD->AFR[0] |= (7 << 20); //Setup TX as the Alternate Function GPIOD->AFR[0] |= (7 << 24); //Setup RX as the Alternate Function USART2->CR1 |= (1 << 13); //Enable USART integerdivider = ((25 * apbclock) / (2 * (BAUD))); tmpreg = (integerdivider / 100) << 4; fractionaldivider = integerdivider - (100 * (tmpreg >> 4)); tmpreg |= ((((fractionaldivider * 8) + 50) / 100)) & ((uint8_t)0x07); USART2->BRR = (uint16_t)tmpreg; USART2->CR1 |= (3 << 2); //Enable Tx & Rx }
     
    Basic Functions:

    void putchar(USART_TypeDef* myUSART, uint32_t data) { myUSART->DR = (char)data; while(((myUSART->SR >> 6) & 0x01) == 0); } void putstr(USART_TypeDef* myUSART, char *data) { while(*data) putchar(myUSART,*data++); }
  5. Like
    atomsoft got a reaction from bluehash in New PCB order service OSH Park from Laen - Dorkbot PDX   
    Yeah, ive been using Dorkbot through email for months already... first time using the site ...
  6. Like
    atomsoft got a reaction from Rickta59 in GPIO - STM32F4   
    /********************************************************************** GPIO Mode Register - GPIOx->MODER 00 = INPUT 01 = OUTPUT 10 = ALTERNATE FUNCTION 11 = ANALOG Example: Make LED pin output **********************************************************************/ #define LED 3 GPIOx->MODER |= (1 << (LED * 2)); //Set to Output /********************************************************************** GPIO Type Register - GPIOx->OTYPER 0 = PUSH-PULL (default) 1 = Open Drain Example: Make LED pin push-pull type **********************************************************************/ #define LED 3 GPIOx->OTYPER &= !(1 << LED); //Set to Push-Pull /********************************************************************** GPIO Output Speed Register - GPIOx->OSPEEDR 00 = 2MHz (Low Speed) 01 = 25MHz (Med. Speed) 10 = 50MHz (Fast Speed) 11 = 100MHz/80MHz (High Speed)(100MHz(30pf) - 80MHz(15pf)) Example: Make LED pin 100MHz **********************************************************************/ #define LED 3 GPIOx->OSPEEDR |= (0x02 << (LED * 2)); //Set Max of 50MHz Speed /********************************************************************** GPIO Pull-Up / Pull-Down Register - GPIOx->PUPDR 00 = No Pull-Up / No Pull-Down 01 = Pull-Up Enabled 10 = Pull-Down Enabled 11 = Reserved Example: LED pin with NO PU/PD **********************************************************************/ #define LED 3 GPIOx->PUPDR |= (0x03 << (LED * 2)); //Set it for NO PUPD /********************************************************************** GPIO Input Data Register - GPIOx->IDR Read Pin State Example: Get input from button **********************************************************************/ #define BTN 2 variable = ((GPIOx->IDR >> BTN) & 1); //Get Button State /********************************************************************** GPIO Output Data Register - GPIOx->ODR Write Pin State Example: Turn on LED **********************************************************************/ #define LED 3 GPIOx->ODR |= (1<<LED); //Turn on LED /********************************************************************** GPIO Bit Set/Reset Register - GPIOx->BSRRn n = H (RESET) n = L (SET) Set or Reset Pins Example: Turn LED On then Off **********************************************************************/ #define LED 3 GPIOx->BSRRL |= (1<<LED); //Turn On LED GPIOx->BSRRH |= (1<<LED); //Turn Off LED /********************************************************************** RCC AHB1 peripheral clock register (RCC_AHB1ENR)(5.3.10 in REF MAN) BIT H = ON BIT L = OFF Example: Enable all GPIO Clocks (A:I) **********************************************************************/ #define ALL_GPIO 0x1FF RCC->AHB1ENR = ALL_GPIO;
     
    GPIO Funtion:

    void ConfigPin(GPIO_TypeDef *myGPIO, uint32_t PIN, uint32_t MODE, uint32_t SPEED, uint32_t PUPD) { /* myGPIO: The GPIOx port for the selected pin MODE: 0 = INPUT .... 1 = OUTPUT .... 2 = ALTERNATE FUNCTION .... 3 = ANALOG SPEED: 0 = 2MHz (Low Speed) .... 1 = 25MHz (Med. Speed) .... 2 = 50MHz (Fast Speed) .... 3 = 100MHz/80MHz (High Speed)(100MHz(30pf) - 80MHz(15pf)) PUPD: 0 = No Pull-Up / No Pull-Down .... 1 = Pull-Up Enabled .... 2 = Pull-Down Enabled .... 3 = Reserved */ myGPIO->MODER |= (MODE << (PIN * 2));//OUTPUT myGPIO->OSPEEDR |= (SPEED << (PIN * 2));//50MHz myGPIO->PUPDR |= (PUPD << (PIN * 2)); //Set it for NO PUPD }
  7. Like
    atomsoft got a reaction from Rickta59 in Turn On LED - STM32F4   
    #include <stm32f4xx.h> #define ALL_GPIO 0x1FF #define LED 15 void main(void) { RCC->AHB1ENR = ALL_GPIO; GPIOD->MODER |= (1 << (LED * 2));//OUTPUT GPIOD->OSPEEDR |= (0x02 << (LED * 2));//50MHz GPIOD->PUPDR &= (0x03 << (LED * 2)); //Set it for NO PUPD GPIOD->BSRRL |= (1<<LED); while(1) { } }
  8. Like
    atomsoft got a reaction from Rickta59 in Config USART2 - STM32F4   
    void ConfigUSART2(uint32_t BAUD, uint32_t apbclock) { uint32_t tmpreg = 0x00; uint32_t integerdivider = 0x00; uint32_t fractionaldivider = 0x00; RCC->APB1ENR = (1 << 17); //Enable USART2 Clock GPIOD->MODER |= (2 << 10); //Setup TX pin for Alternate Function GPIOD->MODER |= (2 << 12); //Setup RX pin for Alternate Function GPIOD->AFR[0] |= (7 << 20); //Setup TX as the Alternate Function GPIOD->AFR[0] |= (7 << 24); //Setup RX as the Alternate Function USART2->CR1 |= (1 << 13); //Enable USART integerdivider = ((25 * apbclock) / (2 * (BAUD))); tmpreg = (integerdivider / 100) << 4; fractionaldivider = integerdivider - (100 * (tmpreg >> 4)); tmpreg |= ((((fractionaldivider * 8) + 50) / 100)) & ((uint8_t)0x07); USART2->BRR = (uint16_t)tmpreg; USART2->CR1 |= (3 << 2); //Enable Tx & Rx }
     
    Basic Functions:

    void putchar(USART_TypeDef* myUSART, uint32_t data) { myUSART->DR = (char)data; while(((myUSART->SR >> 6) & 0x01) == 0); } void putstr(USART_TypeDef* myUSART, char *data) { while(*data) putchar(myUSART,*data++); }
×
×
  • Create New...