SAM4S Xplained Pro SysTick Demo2018-10-19T06:23:28+00:00

ASF version

Tested for ASF version 3.31.0

ASF Modules required 

  • None

Basic Demo

The demo uses the Systick to print a message on the OLED.  To compile this demo it add the necessary modules for the OLED screen:

See System Timer Demo.

Code
#include <asf.h>
#include <string.h>


int main(void)
{
	
	sysclk_init();
	board_init();
	ssd1306_init();
	ssd1306_clear();
	ssd1306_set_page_address(0);
	ssd1306_set_column_address(0);
	
	SysTick_Config( 12000000 ); //A tick every 100ms
}

uint8_t text[] = "Hola Mariana. Quieres cenar?";
uint8_t* pText = text;
uint8_t *char_ptr; 
uint8_t i=0, column=0, page=0;


void SysTick_Handler(void){
		
		//print characters
		if(*pText){
			//write a single character
			char_ptr = font_table[*pText++ - 32];
			for (i = 1; i <= char_ptr[0]; i++) {
				ssd1306_write_data(char_ptr[i]);
			}
			
			//newline
			if(column++ == 35){
				column = 0;
				page++;
				ssd1306_set_column_address(column);
				ssd1306_set_page_address(page);
			}
		}

}