Hi all,
Looking at the information posted about Teensy 3.2, it seems that I should be able to create a hex file through Atollic and load it on to my Teensy 3.2 via the Teensy Loader.
I have created a simple project in Atollic, just trying to get GPIOs to output a logic high. I'm not sure if the problem is in my code or my process.
Here is my code. It doesn't set any pins to logic high :-( I appreciate any help I can get.
main.c
LED.c
Looking at the information posted about Teensy 3.2, it seems that I should be able to create a hex file through Atollic and load it on to my Teensy 3.2 via the Teensy Loader.
I have created a simple project in Atollic, just trying to get GPIOs to output a logic high. I'm not sure if the problem is in my code or my process.
Here is my code. It doesn't set any pins to logic high :-( I appreciate any help I can get.
main.c
Code:
#include "mcu.h"
#include "LED.h"
int main(void)
{
//SystemInit();
LEDInit();
uint32_t i = 0;
/* TODO - Add your application code here */
while (1)
{
i++;
}
return 0;
}
LED.c
Code:
#include "mcu.h"
#include "LED.h"
void LEDInit()
{
// Select correct port control (PORT CH11)
// A0 is pin 20
//PORTA->PCR[0] |= 0b001 << PORT_PCR_MUX_SHIFT;
//PORTA->PCR[0] |= PORT_PCR_DSE_MASK;
for (int i = 0; i < 32; i++) {
PORTA->PCR[i] |= 0b001 << PORT_PCR_MUX_SHIFT;
PORTA->PCR[i] |= PORT_PCR_DSE_MASK;
}
for (int i = 0; i < 32; i++) {
PORTB->PCR[i] |= 0b001 << PORT_PCR_MUX_SHIFT;
PORTB->PCR[i] |= PORT_PCR_DSE_MASK;
}
for (int i = 0; i < 32; i++) {
PORTC->PCR[i] |= 0b001 << PORT_PCR_MUX_SHIFT;
PORTC->PCR[i] |= PORT_PCR_DSE_MASK;
}
for (int i = 0; i < 32; i++) {
PORTD->PCR[i] |= 0b001 << PORT_PCR_MUX_SHIFT;
PORTD->PCR[i] |= PORT_PCR_DSE_MASK;
}
for (int i = 0; i < 32; i++) {
PORTE->PCR[i] |= 0b001 << PORT_PCR_MUX_SHIFT;
PORTE->PCR[i] |= PORT_PCR_DSE_MASK;
}
// Set up GPIO to digital output (GPIO CH49)
//PTA->PDDR |= 1 << 0;
PTA->PDDR = GPIO_PDDR_PDD_MASK;
PTB->PDDR = GPIO_PDDR_PDD_MASK;
PTC->PDDR = GPIO_PDDR_PDD_MASK;
PTD->PDDR = GPIO_PDDR_PDD_MASK;
PTE->PDDR = GPIO_PDDR_PDD_MASK;
LEDOn();
}
void LEDOn()
{
//PTA->PSOR |= 1 << 0;
PTA->PSOR = GPIO_PDDR_PDD_MASK;
PTB->PSOR = GPIO_PDDR_PDD_MASK;
PTC->PSOR = GPIO_PDDR_PDD_MASK;
PTD->PSOR = GPIO_PDDR_PDD_MASK;
PTE->PSOR = GPIO_PDDR_PDD_MASK;
PTA->PDOR = GPIO_PDDR_PDD_MASK;
PTB->PDOR = GPIO_PDDR_PDD_MASK;
PTC->PDOR = GPIO_PDDR_PDD_MASK;
PTD->PDOR = GPIO_PDDR_PDD_MASK;
PTE->PDOR = GPIO_PDDR_PDD_MASK;
}
void LEDOff()
{
PTA->PCOR |= 1 << 0;
}
void LEDToggle()
{
PTA->PTOR |= 1 << 0;
}