Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Thanks... it was nothing... now when i get a LCD working on this ill be happy heh... havent touched it ever since tho
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!
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 ?
#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--;
}
}
#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);
}
the compiler itself doesnt come with anything but the main ST program has a ton of examples... i mean you will get lost in it...
There are a ton heh... there is more down the list. with lots of info in there:
I also love to buy one. But the shipping cost is 5 times more that the product. At Gigikey
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;
}
}