Mikrocontroller und Digitale Elektronik
›
Thread
stm32 und HD4470 Problem
M
Matthias
Gast
03.10.2015 21:39
#4296977
Guten Abend,
ich versuche jetzt seit geraumer Zeit ein Bathron-LDC mit dem STM32F103
anzusteuern. Ich kriege aber nur die Obere der beiden Zeilen angezeigt
und diese nur mit 5*3 Pixeln.
Ich vermute fast das ich was generelles falsch gemacht habe, finde es
aber nicht. Die aus meiner Sicht relevanten Codeabschnitte:
main(void): 1 #include "stm32f10x_conf.h"
2 #include "Delay.h"
3 #include "DS18S20.h"
4 #include "HD4470.h"
5
6 void INIT_GPIO ( void ){
7 GPIO_InitTypeDef GPIO_InitStructure ;
8 SystemInit ();
9 RCC_APB2PeriphClockCmd ( RCC_APB2Periph_GPIOB , ENABLE );
10 GPIO_InitStructure . GPIO_Mode = GPIO_Mode_Out_PP ;
11 GPIO_InitStructure . GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13 ;
12 GPIO_InitStructure . GPIO_Speed = GPIO_Speed_50MHz ;
13 GPIO_Init ( GPIOB , & GPIO_InitStructure );
14 RCC_APB2PeriphClockCmd ( RCC_APB2Periph_GPIOC , ENABLE );
15 GPIO_InitStructure . GPIO_Mode = GPIO_Mode_Out_PP ;
16 GPIO_InitStructure . GPIO_Pin = GPIO_Pin_12 ;
17 GPIO_InitStructure . GPIO_Speed = GPIO_Speed_50MHz ;
18 GPIO_Init ( GPIOC , & GPIO_InitStructure );
19 }
20
21 int main ( void )
22 {
23 uint32_t zeit = 500 ;
24 INIT_GPIO ();
25 GPIO_WriteBit ( GPIOB , GPIO_Pin_12 , ENABLE ); //enable power-supply for DS18S20
26
27 DS18S20_init ();
28 HD4470_init ();
29 //HD4470_sprint("1234567890");
30 Delay_Ms ( zeit );
31
32 while ( 1 )
33 {
34 GPIO_WriteBit ( GPIOC , GPIO_Pin_13 , 1 );
35 Delay_Ms ( zeit );
36 GPIO_WriteBit ( GPIOC , GPIO_Pin_13 , 0 );
37 Delay_Ms ( zeit );
38 }
39 }
HD4470.c 1 #include "HD4470.h"
2 #include "stm32f10x_conf.h"
3 #include "Delay.h"
4 #include <string.h>
5
6 void HD4470_init ( void );
7 void HD4470_clear ( void );
8 void HD4470_command ( int bits , int char_mode );
9 void HD4470_sprint ( char text []);
10
11 void HD4470_init ( void ){
12
13 GPIO_InitTypeDef GPIO_InitStructure ;
14 //PORT A
15 RCC_APB2PeriphClockCmd ( RCC_APB2Periph_GPIOA , ENABLE );
16 GPIO_InitStructure . GPIO_Mode = GPIO_Mode_Out_PP ;
17 GPIO_InitStructure . GPIO_Pin = LCD_Command_RS | LCD_Command_RW | LCD_Command_E ;
18 GPIO_InitStructure . GPIO_Speed = GPIO_Speed_50MHz ;
19 GPIO_Init ( GPIOA , & GPIO_InitStructure );
20 //PORT B
21 RCC_APB2PeriphClockCmd ( RCC_APB2Periph_GPIOB , ENABLE );
22 GPIO_InitStructure . GPIO_Mode = GPIO_Mode_Out_PP ;
23 GPIO_InitStructure . GPIO_Pin = LCD_DataBit_4 | LCD_DataBit_5 | LCD_DataBit_6 | LCD_DataBit_7 ;
24 GPIO_InitStructure . GPIO_Speed = GPIO_Speed_50MHz ;
25 GPIO_Init ( GPIOB , & GPIO_InitStructure );
26
27 HD4470_clear ();
28 }
29
30 void HD4470_clear ( void ){
31 HD4470_command ( 0x33 , 0 );
32 HD4470_command ( 0x32 , 0 );
33 HD4470_command ( 0x06 , 0 );
34 HD4470_command ( 0x0C , 0 );
35 HD4470_command ( 0x28 , 0 );
36 HD4470_command ( 0x01 , 0 );
37 }
38
39 void HD4470_command ( int bits , int char_mode ){
40 if ( char_mode != 1 ) char_mode = 0 ; //wenn charmode nicht explizit 1 ist, muss es 0 sein
41 GPIO_WriteBit ( LCD_Command_RS_PORT , LCD_Command_RS , DISABLE );
42 GPIO_WriteBit ( LCD_Command_RW_PORT , LCD_Command_RW , DISABLE );
43 Delay_Ms ( 1 );
44
45 GPIO_WriteBit ( LCD_DataBit_4_PORT , LCD_DataBit_4 , DISABLE );
46 GPIO_WriteBit ( LCD_DataBit_5_PORT , LCD_DataBit_5 , DISABLE );
47 GPIO_WriteBit ( LCD_DataBit_6_PORT , LCD_DataBit_6 , DISABLE );
48 GPIO_WriteBit ( LCD_DataBit_7_PORT , LCD_DataBit_7 , DISABLE );
49
50 GPIO_WriteBit ( LCD_DataBit_4_PORT , LCD_DataBit_4 ,( bits >> 4 ) & 0x01 );
51 GPIO_WriteBit ( LCD_DataBit_5_PORT , LCD_DataBit_5 ,( bits >> 5 ) & 0x01 );
52 GPIO_WriteBit ( LCD_DataBit_6_PORT , LCD_DataBit_6 ,( bits >> 6 ) & 0x01 );
53 GPIO_WriteBit ( LCD_DataBit_7_PORT , LCD_DataBit_7 ,( bits >> 7 ) & 0x01 );
54
55 // start transmission
56 Delay_us ( 1 );
57 GPIO_WriteBit ( LCD_Command_E_PORT , LCD_Command_E , ENABLE );
58 Delay_us ( 1 );
59 GPIO_WriteBit ( LCD_Command_E_PORT , LCD_Command_E , DISABLE );
60
61 GPIO_WriteBit ( LCD_DataBit_4_PORT , LCD_DataBit_4 ,( bits >> 0 ) & 0x01 );
62 GPIO_WriteBit ( LCD_DataBit_5_PORT , LCD_DataBit_5 ,( bits >> 1 ) & 0x01 );
63 GPIO_WriteBit ( LCD_DataBit_6_PORT , LCD_DataBit_6 ,( bits >> 2 ) & 0x01 );
64 GPIO_WriteBit ( LCD_DataBit_7_PORT , LCD_DataBit_7 ,( bits >> 3 ) & 0x01 );
65
66 // start transmission
67 Delay_us ( 1 );
68 GPIO_WriteBit ( LCD_Command_E_PORT , LCD_Command_E , ENABLE );
69 Delay_us ( 1 );
70 GPIO_WriteBit ( LCD_Command_E_PORT , LCD_Command_E , DISABLE );
71
72 }
73
74 void HD4470_sprint ( char text []){
75 /*for(int i=0; i < strlen(text); ++i){
76 cmd(text[i],1);
77 }*/
78 int i = 0 ;
79 while ( i < strlen ( text )){
80 HD4470_command ( text [ i ], 1 );
81 ++ i ;
82 }
83
84 }
"LCD_Command_E_PORT" und ähnliche wurden in den header-Dateien
definiert.
↑ Nach oben
← Zurück zu Mikrocontroller und Digitale Elektronik
Antwort schreiben
Eine eigene Frage?
Dieser Thread ist über 11 Jahre alt.
Stell sie in einem eigenen Thread – dort lesen mehr Leute mit, und sie wird öfter und schneller beantwortet.
Neuen Thread starten
Eine Lösung, Ergänzung oder Rückmeldung zu diesem Thread? Dann antworte hier.