Nmae of the CS pin in bare metal programming

Status
Not open for further replies.

Shekhar

New member
Hello,

I'm using 3.2 on Ubuntu 16.04 without the Arduino IDE as explained at
http://blogs.omnicron.com/ford/2015/06/17/easy-teensy-development-on-ubuntu/

The following test program is included

Code:
#include  "common.h"

#define  LED_ON		GPIOC_PSOR=(1<<5)
#define  LED_OFF	GPIOC_PCOR=(1<<5)


int  main(void)
{
	volatile uint32_t			n;
	uint32_t					v;
	uint8_t						mask;

	PORTC_PCR5 = PORT_PCR_MUX(0x1); // LED is on PC5 (pin 13), config as GPIO (alt = 1)
	GPIOC_PDDR = (1<<5);			// make this an output pin
	LED_OFF;						// start with LED off

	v = (uint32_t)mcg_clk_hz;
	v = v / 1000000;

	while (1)
	{
		for (n=0; n<1000000; n++)  ;	// dumb delay
		mask = 0x80;
		while (mask != 0)
		{
			LED_ON;
			for (n=0; n<1000; n++)  ;		// base delay
			if ((v & mask) == 0)  LED_OFF;	// for 0 bit, all done
			for (n=0; n<2000; n++)  ;		// (for 1 bit, LED is still on)
			LED_OFF;
			for (n=0; n<1000; n++)  ;
			mask = mask >> 1;
		}
	}

	return  0;						// should never get here!
}

Instead of PC5 (pin 13), I want to toggle pin 10, how can I do it?

Thank you for your help in advance.
 
Agree with Frank... Another option is to look at the Arduino sources...
In particular if you look at the teens3\core_pins.h file

You will find sections for each pin...

Code:
#define CORE_PIN10_BIT		4
#define CORE_PIN10_PORTREG	GPIOC_PDOR

From this you know Arduino pin 10 is C4... Note: I have excel document for T3.5/6 for the different pins. I know others have done the same for other boards as well.
 
Agree with Frank... Another option is to look at the Arduino sources...
In particular if you look at the teens3\core_pins.h file

You will find sections for each pin...

Code:
#define CORE_PIN10_BIT		4
#define CORE_PIN10_PORTREG	GPIOC_PDOR

From this you know Arduino pin 10 is C4... Note: I have excel document for T3.5/6 for the different pins. I know others have done the same for other boards as well.

Thank you for your reply, it helped.
 
Status
Not open for further replies.
Back
Top