View allAll Photos Tagged embeddedprogramming
This is our TinyG Stepper Controller Board. I tossed some code up on the xmega to test inputs from these "encoder ports" All I am doing is putting 3v onto each pin and it turns off the led that corresponds to the port.
===========CODE===============
#include
#include
#define F_CPU 32000000UL
#include
void Config32MHzClock(void);
int main(void)
{
int data;
Config32MHzClock();
CLK.PSCTRL = 0x00; // no division on peripheral clock
PORTCFG.CLKEVOUT = PORTCFG_CLKOUT_PE7_gc;
PORTA.DIR = (1 << 5);
PORTD.DIR = (1 << 5); //Sets Pin5 as an output
PORTD.DIR = (1 << 5);
PORTE.DIR = (1 << 5);
PORTF.DIR = (1 << 5);
//011 PULLUP Totempole Pull-up (on input) is what is set
//PORT A F D E 6 & 7 ENCODER PORTS
PORTA.PIN6CTRL = (0x30); //Sets Pullup on Input on pin 6
PORTA.PIN7CTRL = (0x30); //Sets Pullup on Input on pin 7
PORTF.PIN6CTRL = (0x30); //Sets Pullup on Input on pin 6
PORTF.PIN7CTRL = (0x30); //Sets Pullup on Input on pin 7
PORTD.PIN6CTRL = (0x30); //Sets Pullup on Input on pin 6
PORTD.PIN7CTRL = (0x30); //Sets Pullup on Input on pin 7
PORTE.PIN6CTRL = (0x30); //Sets Pullup on Input on pin 6
PORTE.PIN7CTRL = (0x30); //Sets Pullup on Input on pin 7
PORTA.OUT = (1<<5);
while(1){
if (PORTA.IN & (1<<6))
PORTA.OUT = (0x00);
else if (PORTD.IN & (1<<6))
PORTD.OUT = (0x00);
else if (PORTE.IN & (1<<6))
PORTE.OUT = (0x00);
else if (PORTF.IN & (1<<6))
PORTF.OUT = (0x00);
_delay_ms(10); //Cleans up the light coming back on
PORTA.OUT = (1 << 5);
PORTD.OUT = (1 << 5);
PORTE.OUT = (1 << 5);
PORTF.OUT = (1 << 5);
//_delay_ms(100);
//PORTA.OUT ^= PORTA.OUT;
//PORTD.OUT ^= PORTD.OUT;
//PORTE.OUT ^= PORTE.OUT;
//PORTF.OUT ^= PORTF.OUT;
//_delay_ms(100);
}
}
void Config32MHzClock(void)
{
CCP = CCP_IOREG_gc; //Security Signature to modify clock
// initialize clock source to be 32MHz internal oscillator (no PLL)
OSC.CTRL = OSC_RC32MEN_bm; // enable internal 32MHz oscillator
while(!(OSC.STATUS & OSC_RC32MRDY_bm)); // wait for oscillator ready
CCP = CCP_IOREG_gc; //Security Signature to modify clock
CLK.CTRL = 0x01; //select sysclock 32MHz osc
};
Companies are conducting #PlacementDrive for our students who completed Our Online / Offline Embedded Systems Course.
Join IIES Online / Offline Embedded Course's and get a job in your dream career.
Enroll Now:-
iies.in/certification-courses-freshers/embedded-system-co...
Call/WhatsApp us at (+91) 8041216422 (+91) 9886920008 to know more.
#embeddedsystems #embeddedsystem #embeddedplacement #embeddedprogramming #embeddedprojects #microcontroller #microcontrollers #placement #placementdrive #placements #trainingandplacement #upskill #careercounseling #recruiting #recruitment #iies #linux #engineering #raspberrypi #pcbdesign