Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

STMicro STM8S-Discovery USB EVBU (under $10) ???

Status
Not open for further replies.
Thanks... it was nothing... now when i get a LCD working on this ill be happy heh... havent touched it ever since tho :D

I'm using the Cosmic compiler, but not sure how to download the code into the training kit yet. Anyway, these are nice stuff to play with.

I'll be ordering a 2nd training kit with some cheapo Microchip temperature sensors, and if I have the time, I'll be making a cheap radio-clock! :D

However the DIP versions are not out yet - apparently these STM8S are very new. I hope Farnell or RS will stock up on those stuff.
 
I'm using the Cosmic compiler, but not sure how to download the code into the training kit yet. Anyway, these are nice stuff to play with.

I'll be ordering a 2nd training kit with some cheapo Microchip temperature sensors, and if I have the time, I'll be making a cheap radio-clock! :D

However the DIP versions are not out yet - apparently these STM8S are very new. I hope Farnell or RS will stock up on those stuff.

I use Cosmic as well... I followed the link in the above post.. that was very usefull.. I jumped in without knowing anything about the MCU at all. I still know nothing of it..

Farnell i know of ... whats RS ?
 
I use Cosmic as well... I followed the link in the above post.. that was very usefull.. I jumped in without knowing anything about the MCU at all. I still know nothing of it..

Farnell i know of ... whats RS ?

It's not Radio-Shack which is non-existent in my place. It's RS-Online.

Meanwhile, I'll experiment with the MCU if I'm free. Currently I'm locked down with my college project, assignments and two mid-term tests next week! :D
 
Hey check it out i got a 2x16 lcd working on this STM8S Discovery... nice and easy:

EDIT: I forgot to tell you if using a 5v LCD place JP1 to 5v.... default is 3.3v
Code:
#include "stm8s.h"

#define LCD_PORT   GPIOB
#define LCD_RS 		 GPIO_PIN_0
#define LCD_E 		 GPIO_PIN_1

void DelayMS(int delay);
void initLCD(void);
void LCD_DATA(unsigned char data,unsigned char type);
void LCD_NYB(unsigned char nyb, char type);
void LCD_LINE(char line);
void LCD_STR(const unsigned char *text);

int main(void) {
    
    GPIO_DeInit(LCD_PORT);
    GPIO_Init(LCD_PORT, GPIO_PIN_ALL, GPIO_MODE_OUT_PP_LOW_FAST);
    initLCD();
		
		LCD_LINE(1);
		LCD_STR("  AtomSoftTech  ");
		DelayMS(100);
		LCD_LINE(2);
		LCD_STR("  Jason  Lopez  ");
		DelayMS(100);
	
    while(1);
}
void LCD_STR(const unsigned char *text){
    while(*text){
        LCD_DATA(*text++,1);
    }
}
void initLCD(void){
	  GPIO_WriteLow(LCD_PORT,LCD_E);                    //clear enable
    GPIO_WriteLow(LCD_PORT,LCD_RS);                   //going to write command

    DelayMS(30);                //delay for LCD to initialise.
    LCD_NYB(0x03,0);              //Required for initialisation
    DelayMS(5);                 //required delay
    LCD_NYB(0x03,0);              //Required for initialisation
    DelayMS(1);                 //required delay
    LCD_DATA(0x02,0);           //set to 4 bit interface, 1 line and 5*7 font
    LCD_DATA(0x28,0);           //set to 4 bit interface, 2 line and 5*10 font
    LCD_DATA(0x0c,0);           //set to 4 bit interface, 2 line and 5*7 font
    LCD_DATA(0x01,0);           //clear display
    LCD_DATA(0x06,0);           //move cursor right after write

}
void LCD_DATA(unsigned char data,unsigned char type){
    DelayMS(10);                  //TEST LCD FOR BUSY 
    LCD_NYB(data>>4,type);               //WRITE THE UPPER NIBBLE
    LCD_NYB(data,type);                  //WRITE THE LOWER NIBBLE
}
void LCD_NYB(unsigned char nyb, char type){
    unsigned char temp;
		temp = (nyb<<4) & 0xF0;
    GPIO_Write(LCD_PORT,temp);   
		
		if(type == 0){
        GPIO_WriteLow(LCD_PORT,LCD_RS);       //COMMAND MODE
    } else {
        GPIO_WriteHigh(LCD_PORT,LCD_RS);      //CHARACTER/DATA MODE
    }    
		
    GPIO_WriteHigh(LCD_PORT,LCD_E);          	//ENABLE LCD DATA LINE
    DelayMS(1);            										//SMALL DELAY
    GPIO_WriteLow(LCD_PORT,LCD_E);          	//DISABLE LCD DATA LINE
}
void LCD_LINE(char line){
    switch(line){
        case 0:
        case 1:
            LCD_DATA(0x80,0);
            break;
        case 2:
            LCD_DATA(0xC0,0);
            break;
    }
}
void DelayMS(int delay){
	int nCount = 0;
	while (delay != 0){
		nCount = 100;
		while (nCount != 0){
			nCount--;
		}
		delay--;
	}
}

**broken link removed**

LCD on STM8S Discovery Atomsoft's Blog

Easy enough to make a lib:
Code:
#include "stm8s.h"
#include "lcd.h"

int main(void) {
    
    GPIO_DeInit(LCD_PORT);
    GPIO_Init(LCD_PORT, GPIO_PIN_ALL, GPIO_MODE_OUT_PP_LOW_FAST);
    initLCD();
		
		LCD_LINE(1);
		LCD_STR("  AtomSoftTech  ");
		DelayMS(100);
		LCD_LINE(2);
		LCD_STR("  Jason  Lopez  ");
		DelayMS(100);
	
    while(1);
}
 
Last edited:
There are a ton heh... there is more down the list. with lots of info in there:
**broken link removed**
 

Attachments

  • Clipboard02..jpg
    Clipboard02..jpg
    576.7 KB · Views: 305
Last edited:
Hallo Boys,
I am Michael from Germany. I´ve got the Kit last week and also downloaded the Software. Here is a special offer of the 32k compiler: Cosmic Software
The license i´ve got after 3 minutes. I tried to connect a 4 x 20 LCD on the Kit and it works well. Must add a little code for the LCD Lines:
void LCD_LINE(char line){
switch(line){

case 1:
LCD_DATA(0x80,0);
break;
case 2:
LCD_DATA(0xC0,0);
break;
case 3:
LCD_DATA(0x94,0);
break;
case 4:
LCD_DATA(0xD4,0);
break;
}

thanks to Jason for the lib!
regards Michael
(sorry for errors in my english!)
 
Everyone makes mistakes especially if english isnt the main language... Its my main language and i make mistakes too :D no need to apologize...

Your welcome Im glad to see it was usefull so soon! ... I need to get me a 4 line LCD heh.... I have 2 (2x16) lcds only and a 128x64 GLCD.
Thanks for the additional code.
Code:
void LCD_LINE(char line){
  switch(line){
    case 1:
        LCD_DATA(0x80,0);
        break;
    case 2:
        LCD_DATA(0xC0,0);
        break;
    case 3:
        LCD_DATA(0x94,0);
        break;
    case 4:
        LCD_DATA(0xD4,0);
        break;
  }
}

I know its your first post ... try to use
[ code ]
YOUR CODE HERE
[ /code ]

Without the spaces like
Code:
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top