Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Moreauself

Pages: [1]
1
Graphic LCDs / NHD-12864WX-T1TFH# IN C LANGUAGE !!!
« on: October 19, 2016, 09:05:55 PM »
hey guys !

I'm a Canadian student in electrical engineering and my final project is an alarm clock. I choose to take this display : NHD-12864WX-T1TFH# from New Haven and i need to do my code in C. I tried so hard to start the screen but nothing happened ... i put the pin High and Low when i needed it and nothing happened...

Thanks Guys if you can help me !
I'm so stress about this !

MoreauSelf

** this is the code **

#include <asf.h>
#include "conf_example.h"
#include "Setup_PIN.h"


volatile uint32_t ul_ms_ticks, ti_cur_ticks;

void SysTick_Handler(void){
   ul_ms_ticks++;
}

static void mdelay(uint32_t ul_dly_ticks){
   uint32_t ul_cur_ticks;

   ul_cur_ticks = ul_ms_ticks;
   while ((ul_ms_ticks - ul_cur_ticks) < ul_dly_ticks) {
   }
}


 static void INPUT_OUTPUT (void){
    /* Set output direction on the given LED IOPORTs */
    ioport_set_pin_dir(LED_1, IOPORT_DIR_OUTPUT);
    ioport_set_pin_dir(LED_2, IOPORT_DIR_OUTPUT);
    ioport_set_pin_dir(LED_3, IOPORT_DIR_OUTPUT);
    ioport_set_pin_dir(LED_4, IOPORT_DIR_OUTPUT);
    ioport_set_pin_dir(LED_5, IOPORT_DIR_OUTPUT);
    ioport_set_pin_dir(LED_6, IOPORT_DIR_OUTPUT);
    ioport_set_pin_dir(LED_7, IOPORT_DIR_OUTPUT);
    ioport_set_pin_dir(LED_8, IOPORT_DIR_OUTPUT);
    ioport_set_pin_dir(LCD_P_S, IOPORT_DIR_OUTPUT);
    ioport_set_pin_mode(LCD_P_S, IOPORT_MODE_PULLUP);
    ioport_set_pin_dir(LCD_C86, IOPORT_DIR_OUTPUT);
    ioport_set_pin_mode(LCD_C86, IOPORT_MODE_PULLUP);
    ioport_set_pin_dir(LCD_DB0, IOPORT_DIR_OUTPUT);
    ioport_set_pin_mode(LCD_DB0, IOPORT_MODE_PULLUP);
    ioport_set_pin_dir(LCD_DB1, IOPORT_DIR_OUTPUT);
    ioport_set_pin_mode(LCD_DB1, IOPORT_MODE_PULLUP);
    ioport_set_pin_dir(LCD_DB2, IOPORT_DIR_OUTPUT);
    ioport_set_pin_mode(LCD_DB2, IOPORT_MODE_PULLUP);
    ioport_set_pin_dir(LCD_DB3, IOPORT_DIR_OUTPUT);
    ioport_set_pin_mode(LCD_DB3, IOPORT_MODE_PULLUP);
    ioport_set_pin_dir(LCD_DB4, IOPORT_DIR_OUTPUT);
    ioport_set_pin_mode(LCD_DB4, IOPORT_MODE_PULLUP);
    ioport_set_pin_dir(LCD_DB5, IOPORT_DIR_OUTPUT);
    ioport_set_pin_mode(LCD_DB5, IOPORT_MODE_PULLUP);
    ioport_set_pin_dir(LCD_DB6, IOPORT_DIR_OUTPUT);
    ioport_set_pin_mode(LCD_DB6, IOPORT_MODE_PULLUP);
    ioport_set_pin_dir(LCD_DB7, IOPORT_DIR_OUTPUT);
    ioport_set_pin_mode(LCD_DB7, IOPORT_MODE_PULLUP);
    ioport_set_pin_dir(LCD_E, IOPORT_DIR_OUTPUT);
    ioport_set_pin_mode(LCD_E, IOPORT_MODE_PULLUP);
    ioport_set_pin_dir(LCD_R_W, IOPORT_DIR_OUTPUT);
    ioport_set_pin_mode(LCD_R_W, IOPORT_MODE_PULLUP);
    ioport_set_pin_dir(LCD_A0, IOPORT_DIR_OUTPUT);
    ioport_set_pin_mode(LCD_A0, IOPORT_MODE_PULLUP);
    ioport_set_pin_dir(LCD_RES, IOPORT_DIR_OUTPUT);
    ioport_set_pin_mode(LCD_RES, IOPORT_MODE_PULLUP);
    ioport_set_pin_dir(LCD_CS2, IOPORT_DIR_OUTPUT);
    ioport_set_pin_mode(LCD_CS2, IOPORT_MODE_PULLUP);
    ioport_set_pin_dir(LCD_CS1, IOPORT_DIR_OUTPUT);
    ioport_set_pin_mode(LCD_CS1, IOPORT_MODE_PULLUP);
    ioport_set_pin_dir(BUZZER, IOPORT_DIR_OUTPUT);
    ioport_set_pin_mode(BUZZER, IOPORT_MODE_PULLUP);
   

    /* Set direction and pullup on the given button IOPORT */
    ioport_set_pin_dir(BUTTON_HEURES, IOPORT_DIR_INPUT);
    ioport_set_pin_mode(BUTTON_HEURES, IOPORT_MODE_PULLUP);
    ioport_set_pin_dir(BUTTON_MINUTES, IOPORT_DIR_INPUT);
    ioport_set_pin_mode(BUTTON_MINUTES, IOPORT_MODE_PULLUP);
    ioport_set_pin_dir(BUTTON_ALARME, IOPORT_DIR_INPUT);
    ioport_set_pin_mode(BUTTON_ALARME, IOPORT_MODE_PULLUP);
   
 }

static void Bip_Depart (void){
   ioport_set_pin_level(BUZZER, true);
   mdelay(100);
   ioport_set_pin_level(BUZZER, false);
   mdelay(100);
   ioport_set_pin_level(BUZZER, true);
   mdelay(100);
   ioport_set_pin_level(BUZZER, false);
}


int main(void)
{
    if(SysTick_Config(sysclk_get_cpu_hz()/1000)){
       printf("tes dans le trouble!\n");
    }
   
   

   INPUT_OUTPUT();
   Bip_Depart();
   
   
   while (true) {
      
         //false = 0
         //false = 1
         
         //Start Screen
         ioport_set_pin_level(LCD_A0, false);
         ioport_set_pin_level(LCD_CS1, false);
         ioport_set_pin_level(LCD_CS2, true);
         ioport_set_pin_level(LCD_RES, true);
         ioport_set_pin_level(LCD_R_W, true);
         ioport_set_pin_level(LCD_E, true);
         ioport_set_pin_level(LCD_C86, true);
         ioport_set_pin_level(LCD_P_S, true);
         ioport_set_pin_level(LCD_DB7, true);
         ioport_set_pin_level(LCD_DB6, false);
         ioport_set_pin_level(LCD_DB5, true);
         ioport_set_pin_level(LCD_DB4, false);
         ioport_set_pin_level(LCD_DB3, true);
         ioport_set_pin_level(LCD_DB2, true);
         ioport_set_pin_level(LCD_DB1, true);
         ioport_set_pin_level(LCD_DB0, true);
         
      
      
   }
   
   
}

Pages: [1]