Associate
February 26, 2015
Question
Problem with connect stm32f0discovery and LCDTS1620A-21
- February 26, 2015
- 4 replies
- 1624 views
Posted on February 26, 2015 at 17:53
and this is my code
hi
i want show a text in LCD and i use LCDTS1620A-21 and stm32f0discovery
and this is my code
#include ''stm32f0xx.h''
uint32_t TickValue=0;
#define RS GPIO_BRR_BR_13 // RS is named as Port 13
#define RW GPIO_BRR_BR_14 // RW is named as Port 14
#define EN GPIO_BRR_BR_15 // EN is named as Port 15
void
initgpio()
{
RCC->AHBENR |= RCC_AHBENR_GPIOCEN;
RCC->AHBENR |= RCC_AHBENR_GPIOAEN;
GPIOC->MODER |= (GPIO_MODER_MODER13_0 | GPIO_MODER_MODER14_0 | GPIO_MODER_MODER15_0) ;
GPIOC->OSPEEDR |= (GPIO_OSPEEDER_OSPEEDR13 | GPIO_OSPEEDER_OSPEEDR14 | GPIO_OSPEEDER_OSPEEDR15);
GPIOC->OTYPER &= ~(GPIO_OTYPER_OT_13 | GPIO_OTYPER_OT_14 | GPIO_OTYPER_OT_15) ;
// GPIOC->PUPDR &= ~(GPIO_PUPDR_PUPDR13 | GPIO_PUPDR_PUPDR14 | GPIO_PUPDR_PUPDR15);
GPIOA->MODER |= (GPIO_MODER_MODER0_0 | GPIO_MODER_MODER1_0 | GPIO_MODER_MODER2_0 |
GPIO_MODER_MODER3_0 | GPIO_MODER_MODER4_0 | GPIO_MODER_MODER5_0 | GPIO_MODER_MODER6_0 | GPIO_MODER_MODER7_0) ;
GPIOA->OSPEEDR |= (GPIO_OSPEEDER_OSPEEDR0 | GPIO_OSPEEDER_OSPEEDR1 | GPIO_OSPEEDER_OSPEEDR2 |
GPIO_OSPEEDER_OSPEEDR3 | GPIO_OSPEEDER_OSPEEDR4 | GPIO_OSPEEDER_OSPEEDR5 | GPIO_OSPEEDER_OSPEEDR6 | GPIO_OSPEEDER_OSPEEDR7);
GPIOA->OTYPER &= ~(GPIO_OTYPER_OT_0 | GPIO_OTYPER_OT_1 | GPIO_OTYPER_OT_2 | GPIO_OTYPER_OT_3 |
GPIO_OTYPER_OT_4 | GPIO_OTYPER_OT_5 | GPIO_OTYPER_OT_6 | GPIO_OTYPER_OT_7) ;
// GPIOA->PUPDR &= ~(GPIO_PUPDR_PUPDR0 | GPIO_PUPDR_PUPDR1 | GPIO_PUPDR_PUPDR2 |
// GPIO_PUPDR_PUPDR3 | GPIO_PUPDR_PUPDR4 | GPIO_PUPDR_PUPDR5 | GPIO_PUPDR_PUPDR6 | GPIO_PUPDR_PUPDR7);
}
void
s_init()
{
GPIOC->BRR=RS;
GPIOC->BRR=RW;
}
void
s_data()
{
GPIOC->BSRR=RS;
GPIOC->BRR=RW;
}
void
delay_ms(uint32_t n_ms)
{
SysTick_Config(8000*3 - 30);
TickValue = n_ms;
while
(TickValue == n_ms)
;
SysTick_Config(8000*3);
while
(TickValue != 0)
;
}
void
s_latch()
{
GPIOC->BSRR=EN;
delay_ms(10);
GPIOC->BRR=EN;
delay_ms(10);
}
void
TimingDelay_Decrement(
void
)
{
TickValue--;
}
int
main(
void
)
{
int
k=0;
char
a[]=
''WWW.EEHERALD.COM''
;
char
b[]=
''EMBEDDED SYSTEMS''
;
initgpio();
GPIOC->BRR=RS;
//Initialize RS=0 for selecting instruction Send
GPIOC->BRR=RW;
// Select RW=0 to write Instruction/data on LCD
GPIOC->BSRR=EN;
// EN=1 for unlatch. (used at initial condition)
delay_ms(10);
s_init();
//Call Instruction Select routine
GPIOA->ODR=0x0001;
// Clear Display, Cursor to Home
s_latch();
//Latch the above instruction
GPIOA->ODR=0x0038;
// Display Function (2 rows for 8-bit data; small)
s_latch();
//Latch this above instruction 4 times
s_latch();
s_latch();
s_latch();
GPIOA->ODR=0x000E;
// Display and Cursor on, Cursor Blink off
s_latch();
//Latch the above instruction
GPIOA->ODR=0x0010;
// Cursor shift left
s_latch();
//Latch the above instruction
GPIOA->ODR=0x0006;
// Cursor Increment, Shift off
s_data();
//Change the input type to Data.(before it was instruction input)
s_latch();
//Latch the above instruction
for
(k=0;a[k];k++)
{
GPIOA->ODR=a[k];
//It will send a[0]='P' as = '0x0050' on Port A.
s_latch();
//Latch the above instruction only once. Or it will clone each character twice if you latch twice.
}
GPIOC->BRR=RS;
//Initialize RS=0 for selecting instruction Send
GPIOC->BRR=RW;
// Select RW=0 to write Instruction/data on LCD
GPIOC->BSRR=EN;
// EN=1 for unlatch. (used at initial condition)
delay_ms(10);
GPIOA->ODR=0x00C0;
// Move cursor to beginning of second row
s_latch();
//Latch the above instruction
s_data();
//Change the input type to Data.(before it was instruction input)
for
(k=0;b[k];k++)
{
GPIOA->ODR=b[k];
//It will send b[0]='E' as = '0x0044' on Port A.
s_latch();
//Latch the above instruction only once. Or it will clone each character twice if you latch twice.
}
s_init();
} but dont work :((((((((((
plz help me
i am a beginerrrrrrrrr
#stm32f0discovery #lcdts1620a-21