TODOPIC

Microcontroladores PIC => dsPIC => Mensaje iniciado por: RedPic en 14 de Diciembre de 2007, 06:07:11

Título: Explorer 16 y QVGA: Primeros Pasos
Publicado por: RedPic en 14 de Diciembre de 2007, 06:07:11
¡¡¡ Que ganas tenía de poder postear en este subforo de dsPIC's !!!  :mrgreen:

Acabo de pedirme esto así que ya tendréis noticias mías con mis experimentos con los dsPIC's  :D :D :D

(http://publi.garcia-cuervo.net/explorer16_plus_qvga.jpg)


Título: Re: Explorer 16 y QVGA
Publicado por: Nocturno en 14 de Diciembre de 2007, 07:03:49
Desde que has encontrado el primo de Zumosol te has vuelto inaguantable  :D
Título: Re: Explorer 16 y QVGA
Publicado por: RedPic en 14 de Diciembre de 2007, 08:08:08
Por cierto ¿hay algún dsPIC con USB? Porque en el Parametric Search no veo que sea posible ni seleccionarlo.  :shock:
Título: Re: Explorer 16 y QVGA
Publicado por: Nocturno en 14 de Diciembre de 2007, 08:38:23
No hay ninguno. Dicen que sacaran en breve 24f con usb y ethernet, pero dada de dsPIC.
Título: Re: Explorer 16 y QVGA
Publicado por: blackcat en 15 de Diciembre de 2007, 01:06:40
Hace poco adquiri la QVGA y esta genial ... tiene touch screen y la libreria esta fenomenal botones, fondos, graficos, de todo ..... lastima que solo funciona en pics 24 ..
Título: Re: Explorer 16 y QVGA
Publicado por: Sispic en 15 de Diciembre de 2007, 13:34:30
Es de color esta QVGA ?

Asi que tambien te has pasado a la formula 1  :lol:
Nos vemos en  boxes .
Título: Re: Explorer 16 y QVGA
Publicado por: RedPic en 15 de Diciembre de 2007, 15:28:05

Nos vemos en  boxes .


Ten cuidado porque voy a montar unos pistones "arrecortados" de baja falda. Y con los muelles "apretaos" pa las valvulas y las bujías de triple electrodo son un cañón. Arranca a un cuarto de vuelta y lo único que me preocupa es que negociando una paella, dándole al grifo a tope, se me acumule el trabajo, no pueda quitar to'los hierros y me compre una parcela pa mi solo y aparque de mala manera.1  Ja, ja, ja  :D :D :D

1 Jerga usada por los aficionados al motor en España sobre los años 70-80
Título: Re: Explorer 16 y QVGA
Publicado por: Sispic en 15 de Diciembre de 2007, 15:58:28
Nada hombre , no vendra de de unos rebolcones mas hasta domarlo y mientras mantienes la parcela limpia (sin hiervajos)  :D.
Ademas con estos motores de microchip  hay que poner mas de piloto para compensar la falta de motor .
Haver que hierro nos traen .
Título: Re: Explorer 16 y QVGA
Publicado por: blackcat en 15 de Diciembre de 2007, 16:52:21
Si de 65k ...

    *  QVGA (320x240) LCD module with resistive touch screen
    * 65K color support
    * Supports portrait and landscape orientations
    * 4 Megabit (512Kx8) flash memory for graphic data storage (optional)
    * Buzzer
    * Horizontal PICtail™ Plus Daughter Board connection interface

Graphics PICtail (http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en532570)
Título: Re: Explorer 16 y QVGA
Publicado por: blackcat en 18 de Diciembre de 2007, 13:54:50
La verdad la verdad ... esta muy bonito ... y la libreria se ve facil de utilizar algo asi tipo JAVA para hacer paneles, forms, etc ... todavia no he podido experimentar porque estoy bastante ocupado en otro proyecto pero apenas termine le entro a eso ... les cuento que tambien me gustaria hacer un tutorial completo sobre filtros IIR en el dspic para publicarlo en este foro .. creo que ya me hice experto en eso  :lol: ...
Título: Re: Explorer 16 y QVGA
Publicado por: RedPic en 27 de Diciembre de 2007, 14:58:49
Primera Entrega.

(http://picmania.garcia-cuervo.net/images/explorer-16_microchip_01.jpg)

(http://picmania.garcia-cuervo.net/images/explorer-16_microchip_02.jpg)

(http://picmania.garcia-cuervo.net/images/explorer-16_microchip_03.jpg)

(http://picmania.garcia-cuervo.net/images/explorer-16_microchip_04.jpg)

(http://picmania.garcia-cuervo.net/images/explorer-16_microchip_05.jpg)

(http://picmania.garcia-cuervo.net/images/explorer-16_microchip_06.jpg)

Ya os iré contando.  :mrgreen:

Título: Re: Explorer 16 y QVGA
Publicado por: blackcat en 27 de Diciembre de 2007, 15:16:09
Te recomiendo que le heches un ojo al MicroC/OS-II de micrium ... esta muy pero muy bueno y facil de usar ... tienen un APP para ese kit ... excelente compra yo tengo varios y no me arrepiento de haberlos comprado ... creo que es el mejor kit de microchip con los modulos de expasion pictail plus, el modulo ethernet es buenisimo ..... ademas ya viste los modulos con PIC32???

MicroC/OS (http://www.micrium.com)
Título: Re: Explorer 16 y QVGA
Publicado por: RedPic en 27 de Diciembre de 2007, 17:33:44
Por primera vez en mi vida, Is the first time, he programado un dsPIC (solo he modificado mínimamente uno de los ejemplos pero algo es algo). Al menos me he demostrado que soy capaz de instalar el MPLAB y el C30 y no perderme por el camino, modificar el programa, instalar el ICD2 y programar el 24FJ128GA010 sin que suelte humos nocivos a la atmósfera  :mrgreen: :mrgreen: :mrgreen:

(http://picmania.garcia-cuervo.net/images/explorer-16_microchip_07.jpg)

Título: Re: Explorer 16 y QVGA
Publicado por: Nocturno en 27 de Diciembre de 2007, 17:38:38
Es que eres un verdadero crack, abuelo.

Sólo un pequeño detalle, que espero no arruine tus ilusiones. Ese micro no es un dsPIC; sólo es un magnífico 24F.
Título: Re: Explorer 16 y QVGA
Publicado por: RedPic en 27 de Diciembre de 2007, 18:00:21

Sólo un pequeño detalle, que espero no arruine tus ilusiones. Ese micro no es un dsPIC; sólo es un magnífico 24F.


Ya decía yo que no podía salir todo bien. Ja, ja, ja  :D :D :D

¿Y el 33FJ256GP710 sí es dsPIC? Porque lo tengo aquí al lado montado sobre su zócalo PIM mirándome con ojos de tierno corderito ...  :mrgreen: :mrgreen: :mrgreen:
Título: Re: Explorer 16 y QVGA
Publicado por: Nocturno en 27 de Diciembre de 2007, 18:07:19
Por ahí vamos bien, sí señor.
Título: Re: Explorer 16 y QVGA
Publicado por: RedPic en 27 de Diciembre de 2007, 18:12:02
Pues a ver si consigo hacer un Wink de Led con profesionalidad, seriedad, economía de medios y presteza o prestancia absolutas e incluso relativas. Ja, ja, ja  :D :D :D
Título: Re: Explorer 16 y QVGA
Publicado por: RedPic en 27 de Diciembre de 2007, 18:16:35
Lo que si he notado, y es un fastidio, que el puñetero ICD2 deja tieso al PIC que no se pone a correr el programa hasta que le desconecto el cablecillo telefónico del programador. Así que compilo, conecto el ICD2, lo programo, desconecto el ICD2 y entonces veo el resultado.

No es como el GTP-USB+ y el WinPic que desde el CCS C lo llamo, se programa el PIC y sale corriendo como alma que lleva el diablo sin tener que poner ni quitar nada.
Título: Re: Explorer 16 y QVGA
Publicado por: Modulay en 27 de Diciembre de 2007, 18:40:16
A ver si va a ser por el fuse DEBUG o algo de eso,o que mantiene al micro reseteado
Título: Re: Explorer 16 y QVGA
Publicado por: omix en 27 de Diciembre de 2007, 19:15:56
Echale un vistazo a la botonera del mplab, porque hay un boton que tiene el simbolito de un flanco de reloj que se usa precisamente para sacar al micro del reset o resetearlo y no hay necesidad de desconectar el ICD2.

Saludos.
Título: Re: Explorer 16 y QVGA
Publicado por: Nocturno en 28 de Diciembre de 2007, 02:55:09
¿Y no puedes conectar el GTPUSB PLUS?
Título: Re: Explorer 16 y QVGA
Publicado por: RedPic en 28 de Diciembre de 2007, 08:04:16
¿Y no puedes conectar el GTPUSB PLUS?

Estoy mirando donde enchufarlo  :mrgreen:
Título: Re: Explorer 16 y QVGA
Publicado por: RedPic en 28 de Diciembre de 2007, 09:50:08
Esta vez parece que si, que he logrado modificar, compilar y programar un dsPIC, Ea  :mrgreen: :mrgreen: :mrgreen:

(http://picmania.garcia-cuervo.net/images/explorer-16_microchip_08.jpg)

Ahora voy a abrir un proyecto nuevo e ir construyendo, capa a capa, un complejísimo Wink_Led. Ja, ja, ja  :D :D :D
Título: Re: Explorer 16 y QVGA
Publicado por: RedPic en 28 de Diciembre de 2007, 11:03:15
Primer programa que es obligatorio hacer: El Winky de un led (en este caso todos los Leds conectados al PORTA del dsPIC33FJ256GP710 en la Explorer-16)  :mrgreen: :mrgreen: :mrgreen:

Main_Wink.c

Código: C#
  1. /**********************************************************************
  2. * © 2007 PicManía By RedRaven
  3. *        http://picmania.garcia-cuervo.net
  4. *
  5. * FileName:        main_wink.c
  6. * Dependencies:    p33FJ256GP710.h
  7. * Processor:       dsPIC33F
  8. * Compiler:        MPLAB® C30 v2.01 or higher
  9. *
  10. * Wink Led Port A
  11. *
  12. * C30 Optimization Level: -O1
  13. *
  14. **********************************************************************/
  15.  
  16. #include "p33FJ256GP710.h"
  17. #include "delay.h"
  18.  
  19. _FOSCSEL(FNOSC_PRIPLL);
  20. _FOSC(FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMD_XT);
  21. _FWDT(FWDTEN_OFF);
  22.  
  23. int main ( void ){
  24.  
  25.     //The settings below set up the oscillator and PLL for 16 MIPS
  26.     PLLFBD = 0x00A0;
  27.     CLKDIV = 0x0048;
  28.  
  29.         /* set LEDs (D3-D10/RA0-RA7) drive state low */
  30.         LATA = 0xFF00;
  31.         /* set LED pins (D3-D10/RA0-RA7) as outputs */
  32.         TRISA = 0xFF00;
  33.      
  34.     /* Infinite Loop */
  35.     while(1){
  36.  
  37.                 // All PORTA to ON
  38.                 LATA = 0xFFFF;
  39.                 // Wait 0.5 seconds
  40.                 Delay(Delay_5mS_Cnt * 100);
  41.                 // All PORTA to OFF
  42.                 LATA = 0xFF00;
  43.                 // Wait 0.5 seconds
  44.                 Delay(Delay_5mS_Cnt * 100);
  45.         };
  46. }

Delay.c

Código: C#
  1. /*********************************************************************
  2.  *
  3.  *                    Simple Delay Routines
  4.  *
  5.  *********************************************************************
  6.  * FileName:        delay.c
  7.  * Dependencies:    delay.h
  8.  * Processor:       dsPIC33F
  9.  * Complier:        MPLAB C30 v2.01.00 or higher
  10.  *
  11.  * Company:         Microchip Technology, Inc.
  12.  *
  13.  * Software License Agreement
  14.  *
  15.  * The software supplied herewith by Microchip Technology Incorporated
  16.  * (the “Company”) for its dsPIC30F Microcontroller is intended
  17.  * and supplied to you, the Company’s customer, for use solely and
  18.  * exclusively on Microchip's dsPIC30F Microcontroller products.
  19.  * The software is owned by the Company and/or its supplier, and is
  20.  * protected under applicable copyright laws. All rights are reserved.
  21.  * Any use in violation of the foregoing restrictions may subject the
  22.  * user to criminal sanctions under applicable laws, as well as to
  23.  * civil liability for the breach of the terms and conditions of this
  24.  * license.
  25.  *
  26.  * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
  27.  * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
  28.  * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  29.  * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
  30.  * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
  31.  * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
  32.  *
  33.  * Author               Date    Comment
  34.  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  35.  * Richard Fischer      7/14/05 Initial release for LCD support
  36.  * Priyabrata Sinha     1/27/06 Ported to non-prototype devices
  37.  *
  38.  ********************************************************************/
  39.  
  40. #include "delay.h"
  41.  
  42. unsigned int temp_count;
  43.  
  44. void Delay( unsigned int delay_count )
  45. {
  46.         temp_count = delay_count +1;
  47.         asm volatile("outer: dec _temp_count");
  48.         asm volatile("cp0 _temp_count");
  49.         asm volatile("bra z, done");
  50.         asm volatile("do #3200, inner" );      
  51.         asm volatile("nop");
  52.         asm volatile("inner: nop");
  53.         asm volatile("bra outer");
  54.         asm volatile("done:");
  55. }
  56.        
  57.  
  58. void Delay_Us( unsigned int delayUs_count )
  59. {
  60.         temp_count = delayUs_count +1;
  61.         asm volatile("outer1: dec _temp_count");       
  62.         asm volatile("cp0 _temp_count");
  63.         asm volatile("bra z, done1");
  64.         asm volatile("do #1500, inner1" );     
  65.         asm volatile("nop");
  66.         asm volatile("inner1: nop");
  67.         asm volatile("bra outer1");
  68.         asm volatile("done1:");
  69. }

Delay.h

Código: C#
  1. //#define Fcy  14754600
  2. #define Fcy  16000000
  3.  
  4. void Delay( unsigned int delay_count );
  5. void Delay_Us( unsigned int delayUs_count );
  6.  
  7. #define Delay200uS_count  (Fcy * 0.0002) / 1080
  8. #define Delay_1mS_Cnt     (Fcy * 0.001) / 2950
  9. #define Delay_2mS_Cnt     (Fcy * 0.002) / 2950
  10. #define Delay_5mS_Cnt     (Fcy * 0.005) / 2950
  11. #define Delay_15mS_Cnt    (Fcy * 0.015) / 2950
  12. #define Delay_1S_Cnt      (Fcy * 1) / 2950

Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: RedPic en 28 de Diciembre de 2007, 15:50:52
Una pequeña modificacion del programa anterior, en vez de Blinkear los 8 primeros bits del PORTA los hacemos lucir uno a uno.  :mrgreen:

Código: C#
  1. /**********************************************************************
  2. * © 2007 PicManía By RedRaven
  3. *        http://picmania.garcia-cuervo.net
  4. *
  5. * FileName:        main_wink.c
  6. * Dependencies:    p33FJ256GP710.h
  7. * Processor:       dsPIC33F
  8. * Compiler:        MPLAB® C30 v2.01 or higher
  9. *
  10. * Wink Led Each Port A
  11. *
  12. * C30 Optimization Level: -O1
  13. *
  14. **********************************************************************/
  15.  
  16. #include "p33FJ256GP710.h"
  17. #include "delay.h"
  18.  
  19. _FOSCSEL(FNOSC_PRIPLL);
  20. _FOSC(FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMD_XT);
  21. _FWDT(FWDTEN_OFF);
  22.  
  23. int main ( void ){
  24.  
  25.  
  26.         unsigned int fA;
  27.  
  28.     //The settings below set up the oscillator and PLL for 16 MIPS
  29.     PLLFBD = 0x00A0;
  30.     CLKDIV = 0x0048;
  31.  
  32.         /* set LEDs (D3-D10/RA0-RA7) drive state low */
  33.         LATA = 0xFF00;
  34.         /* set LED pins (D3-D10/RA0-RA7) as outputs */
  35.         TRISA = 0xFF00;
  36.      
  37.         fA=0x0001;
  38.  
  39.     /* Infinite Loop */
  40.     while(1){
  41.  
  42.                 // Each PORTA to ON
  43.                 LATA = 0xFF00 +(fA);
  44.                 fA = (fA << 1);
  45.                 if(fA==0x0100){
  46.                         fA = 0x0001;
  47.                 }
  48.                 // Wait 0.5 seconds
  49.                 Delay(Delay_5mS_Cnt * 10);
  50.                 // All PORTA to OFF
  51.                 LATA = 0xFF00;
  52.                 // Wait 0.5 seconds
  53.                 Delay(Delay_5mS_Cnt * 10);
  54.         };
  55. }
Título: Re: Explorer 16 y QVGA
Publicado por: MGLSOFT en 28 de Diciembre de 2007, 17:33:49
Lo que si he notado, y es un fastidio, que el puñetero ICD2 deja tieso al PIC que no se pone a correr el programa hasta que le desconecto el cablecillo telefónico del programador. Así que compilo, conecto el ICD2, lo programo, desconecto el ICD2 y entonces veo el resultado.

No es como el GTP-USB+ y el WinPic que desde el CCS C lo llamo, se programa el PIC y sale corriendo como alma que lleva el diablo sin tener que poner ni quitar nada.
No tiene un boton de Run para hacer arrancar el programa desde la interfaz del ICD2 ??? :shock: :shock:
Título: Re: Explorer 16 y QVGA
Publicado por: RedPic en 28 de Diciembre de 2007, 17:44:17

No tiene un boton de Run para hacer arrancar el programa desde la interfaz del ICD2 ??? :shock: :shock:


Si, el amigo Omix me dio la solución. Tiene un par de botones con un flanco de subida uno y de bajada el otro, que controlan el estado del MCLR. Cuando el ICD2 programa activa el del blanco de subida, después de programar le doy a ese botón y el programa empieza a correr.  :mrgreen:

 
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: RedPic en 28 de Diciembre de 2007, 17:48:25
Otro pasito adelante. Esta vez le toca a la USART leyendo y escribiendo por el canal serie.

Aquí tenéis un programita que primero se presenta a si mismo, como todo dsPIC de buena familia, y después se pone a la escucha del canal serie (por la USART2 que es la que el hardware de la Explorer 16 tiene el MAX232 conectado) y devuelve por ese mismo canal lo que reciba, hace el eco.  :mrgreen: :mrgreen: :mrgreen:

(http://picmania.garcia-cuervo.net/images/explorer-16_microchip_09_dump_uart.jpg)

Código: C#
  1. /**********************************************************************
  2. * © 2007 PicManía By RedRaven
  3. *        http://picmania.garcia-cuervo.net
  4. *
  5. * FileName:        main_usart.c
  6. * Dependencies:    p33FJ256GP710.h
  7. * Processor:       dsPIC33F
  8. * Compiler:        MPLAB® C30 v2.01 or higher
  9. *
  10. * Wink Led Port A
  11. *
  12. * C30 Optimization Level: -O1
  13. *
  14. *********************************************************************
  15. * The Processor starts with the Internal oscillator without PLL enabled
  16. * and then the Clock is switched to PLL Mode.
  17. *********************************************************************/
  18. #include <p33FJ256GP710.h>
  19. #include <delay.h>
  20.  
  21. _FOSCSEL(FNOSC_FRC);                                                            // Internal FRC oscillator
  22. _FOSC(FCKSM_CSECMD & OSCIOFNC_OFF  & POSCMD_NONE);  // Clock Switching is enabled and Fail Safe Clock Monitor is disabled
  23.                                                                                                         // OSC2 Pin Function: OSC2 is Clock Output
  24.                                                                                                         // Primary Oscillator Mode: XT Crystanl
  25.  
  26. char mytext[]   ="dsPIC33FJ256GP710 en línea¡\r\nHello TODOPIC (World)\r\n>\0";
  27.  
  28.  
  29.  
  30. void __attribute__ ((interrupt, no_auto_psv)) _U2RXInterrupt(void){
  31.         // Lo que recibo vía UART2 lo pongo en el PORTA ...
  32.         LATA = U2RXREG;
  33.         // ... y lo devuelvo como Echo filtrando el 0x0D para añadir 0x0A
  34.         U2TXREG = U2RXREG;
  35.         if(U2RXREG==0x0D){
  36.                 U2TXREG = 0x0A;
  37.         }
  38.  
  39.         IFS1bits.U2RXIF = 0;
  40. }
  41. void __attribute__ ((interrupt, no_auto_psv)) _U2TXInterrupt(void){
  42.         IFS1bits.U2TXIF = 0;
  43. }
  44.  
  45. void InitClock() {
  46.         PLLFBD                          = 38;   // M  = 40
  47.         CLKDIVbits.PLLPOST      = 0;    // N1 =  2
  48.         CLKDIVbits.PLLPRE       = 0;    // N2 =  2
  49.         OSCTUN                          = 0;
  50.         RCONbits.SWDTEN         = 0;
  51.         // Clock switch to incorporate PLL
  52.         __builtin_write_OSCCONH(0x01);          // Initiate Clock Switch to FRC with PLL (NOSC=0b001)
  53.         __builtin_write_OSCCONL(0x01);          // Start clock switching while (OSCCONbits.COSC != 0b001); Wait for Clock switch to occur
  54.         while(OSCCONbits.LOCK != 1) {};
  55. }
  56.  
  57. void InitUART2() {
  58.         // This is an EXAMPLE, so brutal typing goes into explaining all bit sets
  59.         // The HPC16 board has a DB9 connector wired to UART2, so we will
  60.         // be configuring this port only
  61.         // configure U2MODE
  62.         U2MODEbits.UARTEN = 0;  // Bit15 TX, RX DISABLED, ENABLE at end of func
  63.         //U2MODEbits.notimplemented;    // Bit14
  64.         U2MODEbits.USIDL  = 0;  // Bit13 Continue in Idle
  65.         U2MODEbits.IREN   = 0;  // Bit12 No IR translation
  66.         U2MODEbits.RTSMD  = 0;  // Bit11 Simplex Mode
  67.         //U2MODEbits.notimplemented;    // Bit10
  68.         U2MODEbits.UEN    = 0;  // Bits8,9 TX,RX enabled, CTS,RTS not
  69.         U2MODEbits.WAKE   = 0;  // Bit7 No Wake up (since we don't sleep here)
  70.         U2MODEbits.LPBACK = 0;  // Bit6 No Loop Back
  71.         U2MODEbits.ABAUD  = 0;  // Bit5 No Autobaud (would require sending '55')
  72.         U2MODEbits.URXINV = 0;  // Bit4 IdleState = 1  (for dsPIC)
  73.         U2MODEbits.BRGH   = 0;  // Bit3 16 clocks per bit period
  74.         U2MODEbits.PDSEL  = 0;  // Bits1,2 8bit, No Parity
  75.         U2MODEbits.STSEL  = 0;  // Bit0 One Stop Bit
  76.         // Load a value into Baud Rate Generator.  Example is for 9600.
  77.         // See section 19.3.1 of datasheet.
  78.         //  U2BRG = (Fcy/(16*BaudRate))-1
  79.         //  U2BRG = (37M/(16*9600))-1
  80.         //  U2BRG = 240
  81.         U2BRG = 240;            // 40Mhz osc, 9600 Baud
  82.         // Load all values in for U1STA SFR
  83.         U2STAbits.UTXISEL1 = 0; //Bit15 Int when Char is transferred (1/2 config!)
  84.         U2STAbits.UTXINV   = 0; //Bit14 N/A, IRDA config
  85.         U2STAbits.UTXISEL0 = 0; //Bit13 Other half of Bit15
  86.         //U2STAbits.notimplemented = 0; //Bit12
  87.         U2STAbits.UTXBRK   = 0; //Bit11 Disabled
  88.         U2STAbits.UTXEN    = 0; //Bit10 TX pins controlled by periph
  89.         U2STAbits.UTXBF    = 0; //Bit9 *Read Only Bit*
  90.         U2STAbits.TRMT     = 0; //Bit8 *Read Only bit*
  91.         U2STAbits.URXISEL  = 0; //Bits6,7 Int. on character recieved
  92.         U2STAbits.ADDEN    = 0; //Bit5 Address Detect Disabled
  93.         U2STAbits.RIDLE    = 0; //Bit4 *Read Only Bit*
  94.         U2STAbits.PERR     = 0; //Bit3 *Read Only Bit*
  95.         U2STAbits.FERR     = 0; //Bit2 *Read Only Bit*
  96.         U2STAbits.OERR     = 0; //Bit1 *Read Only Bit*
  97.         U2STAbits.URXDA    = 0; //Bit0 *Read Only Bit*
  98.         IPC7 = 0x4400;                  //Mid Range Interrupt Priority level, no urgent reason
  99.         IFS1bits.U2TXIF    = 0; //Clear the Transmit Interrupt Flag
  100.         IEC1bits.U2TXIE    = 1; //Enable Transmit Interrupts
  101.         IFS1bits.U2RXIF    = 0; //Clear the Recieve Interrupt Flag
  102.         IEC1bits.U2RXIE    = 1; //Enable Recieve Interrupts
  103.         U2MODEbits.UARTEN  = 1; //And turn the peripheral on
  104.         U2STAbits.UTXEN = 1;
  105. }
  106.  
  107. void InitPorts() {
  108.         AD1PCFGHbits.PCFG23 = 1;        // This is important.  RA7 is muxxed with AN23,
  109.                                                                 // So we need to config the pin as DIGITAL
  110.         TRISA = 0x0080;                         // only 0th bit needs be output. A7 is input
  111. }
  112.  
  113. void putUART2( char c){
  114.         while ( U2STAbits.UTXBF); // wait while Tx buffer full
  115.         U2TXREG = c;
  116. }
  117.  
  118. void putsUART2( char *s){
  119.         unsigned int i=0;
  120.         while(s[i])             // loop until *s == ‘\0’, end of string
  121.         putUART2(s[i++]);       // send the character and point to the next one
  122. }
  123.  
  124.  
  125. int main(void) {
  126.        
  127.         InitClock();    // This is the PLL settings
  128.         InitUART2();    // Initialize UART2 for 9600,8,N,1 TX/RX
  129.         InitPorts();    // LEDs outputs
  130.  
  131.         Delay(Delay_5mS_Cnt * 100);
  132.         putsUART2(mytext);
  133.  
  134.         while(1) {              // The ever versatile Infinite Loop! Do Nothing
  135.  
  136.         }
  137. }
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: MGLSOFT en 29 de Diciembre de 2007, 09:11:00
Que es el ultimo >asdfg que aparece en pantalla??
Lo escribes tu??
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: RedPic en 29 de Diciembre de 2007, 10:12:17
Que es el ultimo >asdfg que aparece en pantalla??
Lo escribes tu??

Si, la primera parte "dsPIC33F ...." la saca el dsPIC antes de entrar en el While(1), a partir de ahí lo que hace es hacer eco de lo que recibe por el canal serie y le escribí desde el Siow.exe lo de "asdfg" que él amablemente me devolvió por el mismo medio.  :mrgreen:

Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: RedPic en 29 de Diciembre de 2007, 10:18:27
Y, como nó, ahora viene el mismo Winky del led pero sin delay, haciendo uso de la interrupción del Timer1. (Nota: Estoy estudiando todo el tema de la configuración del Timer1 y mas adelante os pondré los resultados de mis desvelos)

Código: C#
  1. /**********************************************************************
  2. * © 2007 PicManía By RedRaven
  3. *        http://picmania.garcia-cuervo.net
  4. *
  5. * FileName:        main_wink_int_timer1.c
  6. * Dependencies:    p33FJ256GP710.h
  7. * Processor:       dsPIC33F
  8. * Compiler:        MPLAB® C30 v2.01 or higher
  9. *
  10. * Wink Led Port A
  11. *
  12. * C30 Optimization Level: -O1
  13. *
  14. *********************************************************************
  15. * The Processor starts with the Internal oscillator without PLL enabled
  16. * and then the Clock is switched to PLL Mode.
  17. *********************************************************************/
  18. #include <p33FJ256GP710.h>
  19.  
  20. _FOSCSEL(FNOSC_FRC);                           
  21. _FOSC(FCKSM_CSECMD & OSCIOFNC_OFF  & POSCMD_XT);        // Clock Switching Enabled and Fail Safe Clock Monitor is disabled
  22.                                                                                         // OSC2 Pin Function: OSC2 is Clock Output
  23.                                                                                         // Primary Oscillator Mode: XT Crystal
  24. _FWDT(FWDTEN_OFF);                                                         // Watchdog Timer Enabled/disabled by user software
  25.  
  26. unsigned int Count;
  27.  
  28. void __attribute__((interrupt,no_auto_psv)) _T1Interrupt( void ){
  29.        
  30.     IFS0bits.T1IF = 0;
  31.     T1CONbits.TON = 0;
  32.     Count++;
  33.     if(Count == 500){
  34.         Count = 0;  
  35.         LATAbits.LATA1 = ~LATAbits.LATA1;                  
  36.     }
  37.     TMR1          = 0;
  38.     T1CONbits.TON = 1;  // reset Timer 1 interrupt flag
  39. }
  40.  
  41. void InitClock() {
  42.         PLLFBD                  = 38; // M  = 40
  43.         CLKDIVbits.PLLPOST = 0; // N1 =  2
  44.         CLKDIVbits.PLLPRE   = 0; // N2 =  2
  45.         OSCTUN                = 0;
  46.         RCONbits.SWDTEN   = 0;
  47.         // Clock switch to incorporate PLL
  48.         __builtin_write_OSCCONH(0x01);          // Initiate Clock Switch to FRC with PLL (NOSC=0b001)
  49.         __builtin_write_OSCCONL(0x01);          // Start clock switching while (OSCCONbits.COSC != 0b001); Wait for Clock switch to occur
  50.         while(OSCCONbits.LOCK != 1) {};
  51. }
  52.  
  53. void Init_Timer1( void ){
  54.  
  55.     T1CON         = 0;      // Timer reset
  56.     IFS0bits.T1IF = 0;      // Reset Timer1 interrupt flag
  57.     IPC0bits.T1IP = 6;      // Timer1 Interrupt priority level=4
  58.     IEC0bits.T1IE = 1;      // Enable Timer1 interrupt
  59.     TMR1=  0x0000;     
  60.     PR1 =  0xFFFF;          // Timer1 period register = ?????
  61.     T1CONbits.TON = 1;      // Enable Timer1 and start the counter
  62. }
  63.  
  64. int main(void){
  65.        
  66.     RCONbits.SWDTEN=0; // Disable Watch Dog Timer
  67.     InitClock();               // This is the PLL settings
  68.     Init_Timer1();           //  Init Timer1
  69.  
  70.     //Initialize the Ports All PORTA Output
  71.     TRISA = 0x0000;
  72.     LATA  = 0x0000;
  73.     PORTA = 0x0000;
  74.  
  75.     while(1){
  76.        
  77.     };
  78. }
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: Nocturno en 29 de Diciembre de 2007, 10:52:14
Si te sirve de ayuda, échale un vistazo a esto que hice:
33F - Asistente para configurar el Timer de la familia dsPIC33F (http://www.micropic.es/index.php?option=com_content&task=view&id=34&Itemid=58)

Y ya de paso, también tengo estos otros dos:
33F - Asistente para la configuración del oscilador de la familia dsPIC33F  (http://www.micropic.es/index.php?option=com_content&task=view&id=32&Itemid=58)

33F - Asistente para la generación automática de retardos (http://www.micropic.es/index.php?option=com_content&task=view&id=33&Itemid=58)
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: RedPic en 29 de Diciembre de 2007, 11:00:06
Muchas gracias Manolo. Voy a estudiarlos con detenimiento y admiración por quien ha recorrido antes el camino al que yo ahora me estoy enfrentando.  :mrgreen:
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: blackcat en 30 de Diciembre de 2007, 03:11:25
Tenes que seleccionar en debugger al ICD2, en programmer no tiene que estar seleccionado ninguno ... bueno de todas formas cuando selecciones el ICD2 del lado debugger se desactiva automaticamente del lado programmer ... Ahora ves un cuadrito que dice RELEASE ... dale click y selecciona DEBUG ... ahora recompila el codigo y luego dale click al icono de PLAY ... entonces vas a ver todo el potencial de ICD2!!!!!

Podes poner hasta 4 breakpoints en cualquier parte del codigo para detener el programa y con la ventana de WATCH podes ver el estado de TODOS los registros y la memoria .... TODO ESTO CORRIENDO DIRECTAMENTE DEL DSPIC ....

GENIAL ... NO??? Por lo menos es una buena herramienta !
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: blackcat en 30 de Diciembre de 2007, 03:46:46
Hola no se porque no las habia subido ... pero al fin que ya el pic no solo sirve para encender y apagar LEDS  :D :D ... lastima que la libreria es solo para pics 24 y no dspics ... hay que esperar a que microchip lance esa version....

(http://img296.imageshack.us/img296/1149/dsc03563mm8.jpg)
(http://img165.imageshack.us/img165/5039/dsc03564eq7.jpg)
(http://img165.imageshack.us/img165/2302/dsc03565vk2.jpg)

Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: blackcat en 30 de Diciembre de 2007, 04:14:01
INSISTO NUEVAMENTE ....  queres sacarle el maximo provecho a tu pic ??? ... usa:

http://www.micrium.com/microchip/index.html 

Con un RTOS te das cuenta que un micro puede hacer mucho mas de lo que te imaginas...



Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: RedPic en 30 de Diciembre de 2007, 12:01:02
Otro primer paso más. Ahora le toca al conversor AD del dsPIC. En este ejemplo utilizamos el Potenciometro conectado a RA5 (el cursor) y sus extremos entre Vdd y Vss.

Vamos a realizar de forma continua la conversión y vamos a implementar una especie de VUmeter con los 8 leds del PORTA. Con el POT el extremo de Vss apagaremos todos los Leds y en el extremo contrario, a Vdd, los encenderemos todos, con los distintos puntos intermedios encendiendo tantos leds como le toquen.

En este ejemplo configuramos la conversión AD, activamos la Interrupción de dicha conversión y no utilizamos el DMA. O sea lo mas simple posible, que ya habrá tiempo para complicarse la vida.

Código: C#
  1. /**********************************************************************
  2. * © 2007 PicManía By RedRaven
  3. *        http://picmania.garcia-cuervo.net
  4. *
  5. * FileName:        main_ADC_volts_for_Leds.c
  6. * Dependencies:    p33FJ256GP710.h
  7. * Processor:       dsPIC33F
  8. * Compiler:        MPLAB® C30 v2.01 or higher
  9. *
  10. * Wink Led Port A
  11. *
  12. * C30 Optimization Level: -O1
  13. *
  14. **********************************************************************/
  15.  
  16. #include "p33FJ256GP710.h"
  17. #include "delay.h"
  18.  
  19. _FOSCSEL(FNOSC_PRIPLL);
  20. _FOSC(FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMD_XT);
  21. _FWDT(FWDTEN_OFF);
  22.  
  23.  
  24. volatile unsigned int volts_value=0;
  25. volatile unsigned int flag_volts_value=0;
  26.  
  27.  
  28. void init_clock(void){
  29.  
  30.         //The settings below set up the oscillator and PLL for 16 MIPS
  31.         PLLFBD = 0x00A0;
  32.         CLKDIV = 0x0048;
  33. }
  34.  
  35. void init_leds(void){
  36.  
  37.         unsigned int i;
  38.  
  39.         LATA  = 0xFF00;
  40.         TRISA = 0xFF00;
  41.  
  42.         for(i=0; i<3; i++){
  43.                 LATA = 0xFFFF;
  44.                 Delay(Delay_5mS_Cnt * 20);
  45.                 LATA = 0xFF00;
  46.                 Delay(Delay_5mS_Cnt * 20);
  47.         }
  48.  
  49. }
  50.  
  51. void init_ADC( void )
  52. {
  53.  
  54.         /* set port configuration here */              
  55.         AD1PCFGLbits.PCFG5 = 0;         // ensure AN5/RB5 is analog (Analog Pot)
  56.         /* set channel scanning here, auto sampling and convert, with default read-format mode */
  57.         AD1CON1 = 0x00E4;
  58.         /* select 12-bit, 1 channel ADC operation */
  59.         AD1CON1bits.AD12B = 1;
  60.         /* No channel scan for CH0+, Use MUX A, SMPI = 1 per interrupt, Vref = AVdd/AVss */
  61.         AD1CON2 = 0x0000;
  62.         /* Set Samples and bit conversion time */
  63.         AD1CON3 = 0x032F;
  64.         /* set channel scanning here for AN5 */
  65.         AD1CSSL = 0x0000;
  66.         /* channel select AN5 */
  67.         AD1CHS0 = 0x0005;
  68.         /* reset ADC interrupt flag */
  69.         IFS0bits.AD1IF = 0;          
  70.         /* enable ADC interrupts, disable this interrupt if the DMA is enabled */        
  71.         IEC0bits.AD1IE = 1;      
  72.         /* turn on ADC module */
  73.         AD1CON1bits.ADON = 1;  
  74. }
  75.  
  76. void __attribute__((interrupt,no_auto_psv)) _ADC1Interrupt(void){
  77.        
  78.         if(flag_volts_value==0){
  79.                 volts_value = ADC1BUF0; // Save off the RP5 Potentiometer data            
  80.                 flag_volts_value=1;             // set flag to update Leds
  81.         }
  82.         IFS0bits.AD1IF = 0;             // reset ADC interrupt flag
  83. }
  84.  
  85.  
  86. void volts_value_to_leds(void){
  87.  
  88.        
  89.         unsigned int scala,leds;
  90.  
  91.         scala = (unsigned int) volts_value * 0x0007 / 0x0C00;
  92.         leds  = scala;
  93.  
  94.         LATA = 0xFF00;
  95.         if(leds>0) LATA += 0b00000001;
  96.         if(leds>1) LATA += 0b00000010;
  97.         if(leds>2) LATA += 0b00000100;
  98.         if(leds>3) LATA += 0b00001000;
  99.         if(leds>4) LATA += 0b00010000;
  100.         if(leds>5) LATA += 0b00100000;
  101.         if(leds>6) LATA += 0b01000000;
  102.         if(leds>7) LATA += 0b10000000;
  103. }
  104.  
  105.  
  106. int main ( void ){
  107.  
  108.        
  109.     RCONbits.SWDTEN=0; // Disable Watch Dog Timer
  110.  
  111.         init_clock();
  112.         init_leds();
  113.         init_ADC();
  114.      
  115.        
  116.     /* Infinite Loop */
  117.     while(1){
  118.                 if(flag_volts_value==1){
  119.                         flag_volts_value=0;
  120.                         volts_value_to_leds();
  121.                 }
  122.         };
  123. }

Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: RedPic en 30 de Diciembre de 2007, 19:49:44
Bueno, continuamos con nuestras pruebas. Ahora el mas simple "Hello Word" en el LCD. Para ello necesitamos los módulos lcd.c y sus prototipos en lcd.h que adjunto mas abajo.  :mrgreen:

(http://picmania.garcia-cuervo.net/images/explorer-16_microchip_10.jpg)

Código: C#
  1. /**********************************************************************
  2. * © 2007 PicManía By RedRaven
  3. *        http://picmania.garcia-cuervo.net
  4. *
  5. * FileName:        main_LCD_Hello_World.c
  6. * Dependencies:    p33FJ256GP710.h
  7. * Processor:       dsPIC33F
  8. * Compiler:        MPLAB® C30 v2.01 or higher
  9. *
  10. * Present "Hello World" message
  11. *
  12. * C30 Optimization Level: -O1
  13. *
  14. **********************************************************************/
  15.  
  16. #include "p33FJ256GP710.h"
  17. #include "lcd.h"
  18.  
  19. _FOSCSEL(FNOSC_PRIPLL);
  20. _FOSC(FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMD_XT);
  21. _FWDT(FWDTEN_OFF);
  22.  
  23. int main(void){
  24.  
  25.     char mytext1[] = " dsPIC33F - LCD ";
  26.     char mytext2[] = "  Hello World   ";
  27.  
  28.     char *pText1=&mytext1[0];
  29.     char *pText2=&mytext2[0];
  30.        
  31.     //The settings below set up the oscillator and PLL for 16 MIPS
  32.     PLLFBD = 0x00A0;
  33.     CLKDIV = 0x0048;
  34.     // Initialize LCD Display
  35.     Init_LCD();
  36.     // Hellow World message
  37.     home_clr();
  38.     puts_lcd(pText1,sizeof(mytext1)-1);
  39.     line_2();
  40.     puts_lcd(pText2,sizeof(mytext2)-1);
  41.     // Infinite Loop
  42.     while(1){};
  43. }

Código: C#
  1. /**********************************************************************
  2. * © 2006 Microchip Technology Inc.
  3. *
  4. * FileName:        lcd.c
  5. * Dependencies:    p33FJ256GP710.h
  6. *                  lcd.h
  7. *                  delay.h
  8. * Processor:       dsPIC33F
  9. * Compiler:        MPLAB® C30 v2.01 or higher
  10. *
  11. * SOFTWARE LICENSE AGREEMENT:
  12. * Microchip Technology Inc. (“Microchip”) licenses this software to you
  13. * solely for use with Microchip dsPIC® digital signal controller
  14. * products. The software is owned by Microchip and is protected under
  15. * applicable copyright laws.  All rights reserved.
  16. *
  17. * SOFTWARE IS PROVIDED “AS IS.”  MICROCHIP EXPRESSLY DISCLAIMS ANY
  18. * WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING BUT NOT
  19. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  20. * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP
  21. * BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL
  22. * DAMAGES, LOST PROFITS OR LOST DATA, HARM TO YOUR EQUIPMENT, COST OF
  23. * PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
  24. * BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF),
  25. * ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER SIMILAR COSTS.
  26. *
  27. * REVISION HISTORY:
  28. *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  29. * Author            Date      Comments on this revision
  30. *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  31. * Richard Fischer   07/14/05  Explorer 16 board LCD support
  32. * Priyabrata Sinha  01/27/06  Ported to non-prototype devices
  33. *
  34. *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  35. *
  36. * ADDITIONAL NOTES:
  37. *
  38. **********************************************************************/
  39.  
  40. #include "p33FJ256GP710.h"
  41. #include "lcd.h"
  42. #include "delay.h"
  43.        
  44.                
  45. /*
  46.    For Explorer 16 board, here are the data and control signal definitions
  47.    RS -> RB15
  48.    E  -> RD4
  49.    RW -> RD5
  50.    DATA -> RE0 - RE7  
  51. */
  52.  
  53. // Control signal data pins
  54. #define  RW  LATDbits.LATD5       // LCD R/W signal
  55. #define  RS  LATBbits.LATB15      // LCD RS signal
  56. #define  E   LATDbits.LATD4       // LCD E signal
  57. //#define  E   LATFbits.LATF1       // LCD E signal
  58.  
  59. // Control signal pin direction
  60. #define  RW_TRIS        TRISDbits.TRISD5
  61. #define  RS_TRIS        TRISBbits.TRISB15
  62. #define  E_TRIS         TRISDbits.TRISD4
  63. //#define  E_TRIS               TRISFbits.TRISF1
  64.  
  65. // Data signals and pin direction
  66. #define  DATA      LATE           // Port for LCD data
  67. #define  DATAPORT  PORTE
  68. #define  TRISDATA  TRISE          // I/O setup for data Port
  69.  
  70.  
  71.  
  72. /****************************************************************************/
  73. /*****  LCD SUBROUTINE  *****/
  74.  
  75. void Init_LCD( void )             // initialize LCD display
  76. {
  77.         // 15mS delay after Vdd reaches nnVdc before proceeding with LCD initialization
  78.         // not always required and is based on system Vdd rise rate
  79.         Delay(Delay_15mS_Cnt);                  // 15ms delay
  80.                        
  81.         /* set initial states for the data and control pins */
  82.         LATE &= 0xFF00;
  83.     RW = 0;                       // R/W state set low
  84.         RS = 0;                       // RS state set low
  85.         E = 0;                        // E state set low
  86.  
  87.         /* set data and control pins to outputs */
  88.         TRISE &= 0xFF00;
  89.         RW_TRIS = 0;                  // RW pin set as output
  90.         RS_TRIS = 0;                  // RS pin set as output
  91.         E_TRIS = 0;                   // E pin set as output
  92.  
  93.         /* 1st LCD initialization sequence */
  94.         DATA &= 0xFF00;
  95.     DATA |= 0x0038;
  96.     E = 1;     
  97.     Nop();
  98.     Nop();
  99.     Nop();
  100.     E = 0;                        // toggle E signal
  101.         Delay(Delay_5mS_Cnt);         // 5ms delay
  102.      
  103.         /* 2nd LCD initialization sequence */
  104.         DATA &= 0xFF00;
  105.     DATA |= 0x0038;
  106.     E = 1;     
  107.     Nop();
  108.     Nop();
  109.     Nop();     
  110.     E = 0;                        // toggle E signal
  111.     Delay_Us( Delay200uS_count ); // 200uS delay
  112.  
  113.         /* 3rd LCD initialization sequence */
  114.         DATA &= 0xFF00;
  115.     DATA |= 0x0038;
  116.     E = 1;             
  117.     Nop();
  118.     Nop();
  119.     Nop();     
  120.     E = 0;                        // toggle E signal
  121.     Delay_Us( Delay200uS_count ); // 200uS delay
  122.  
  123.     lcd_cmd( 0x38 );              // function set
  124.     lcd_cmd( 0x0C );              // Display on/off control, cursor blink off (0x0C)
  125.     lcd_cmd( 0x06 );                      // entry mode set (0x06)
  126. }
  127.  
  128.  
  129. void lcd_cmd( char cmd )          // subroutiune for lcd commands
  130. {
  131. //      TRISD &= 0xFF00;              // ensure RD0 - RD7 are outputs
  132.         DATA &= 0xFF00;               // prepare RD0 - RD7
  133.     DATA |= cmd;                  // command byte to lcd
  134.         RW = 0;                       // ensure RW is 0
  135.     RS = 0;
  136.     E = 1;                        // toggle E line
  137.     Nop();
  138.     Nop();
  139.     Nop();
  140.     E = 0;
  141.         Delay(Delay_5mS_Cnt);         // 5ms delay
  142. }
  143.  
  144.  
  145. void lcd_data( char data )        // subroutine for lcd data
  146. {
  147. //      TRISD &= 0xFF00;              // ensure RD0 - RD7 are outputs
  148.         RW = 0;                                  // ensure RW is 0
  149.     RS = 1;                       // assert register select to 1
  150.         DATA &= 0xFF00;               // prepare RD0 - RD7
  151.     DATA |= data;                 // data byte to lcd
  152.     E = 1;                             
  153.         Nop();
  154.     Nop();
  155.     Nop();
  156.     E = 0;                       // toggle E signal
  157.     RS = 0;                      // negate register select to 0
  158.     Delay_Us( Delay200uS_count ); // 200uS delay
  159.     Delay_Us( Delay200uS_count ); // 200uS delay
  160. }
  161.  
  162.  
  163. void puts_lcd( unsigned char *data, unsigned int count )
  164. {
  165.         while ( count )
  166.         {
  167.                 lcd_data( *data++ );
  168.                 count --;
  169.         }      
  170. }

Código: C#
  1. /**********************************************************************
  2. * © 2006 Microchip Technology Inc.
  3. *
  4. * FileName:        lcd.h
  5. * Dependencies:    none
  6. * Processor:       dsPIC33F
  7. * Compiler:        MPLAB® C30 v2.01 or higher
  8. *
  9. * SOFTWARE LICENSE AGREEMENT:
  10. * Microchip Technology Inc. (“Microchip”) licenses this software to you
  11. * solely for use with Microchip dsPIC® digital signal controller
  12. * products. The software is owned by Microchip and is protected under
  13. * applicable copyright laws.  All rights reserved.
  14. *
  15. * SOFTWARE IS PROVIDED “AS IS.”  MICROCHIP EXPRESSLY DISCLAIMS ANY
  16. * WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING BUT NOT
  17. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  18. * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP
  19. * BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL
  20. * DAMAGES, LOST PROFITS OR LOST DATA, HARM TO YOUR EQUIPMENT, COST OF
  21. * PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
  22. * BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF),
  23. * ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER SIMILAR COSTS.
  24. *
  25. * REVISION HISTORY:
  26. *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  27. * Author            Date      Comments on this revision
  28. *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  29. * Richard Fischer   07/14/05  Explorer 16 board LCD function support
  30. * Priyabrata Sinha  01/27/06  Ported to non-prototype devices
  31. *
  32. *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  33. *
  34. * ADDITIONAL NOTES:
  35. *
  36. **********************************************************************/
  37.  
  38.  
  39. /****** LCD FUNCTION PROTOYPES ******/
  40.  
  41. void Init_LCD( void );          // initialize display          
  42. void lcd_cmd( char cmd );       // write command to lcd
  43. void lcd_data( char data );     // write data to lcd
  44. void puts_lcd ( unsigned char *data, unsigned int count );
  45.  
  46. /*****  LCD COMMAND FUCNTION PROTOTYPES  *****/
  47. #define cursor_right()  lcd_cmd( 0x14 )
  48. #define cursor_left()   lcd_cmd( 0x10 )
  49. #define display_shift() lcd_cmd( 0x1C )
  50. #define home_clr()      lcd_cmd( 0x01 )
  51. #define home_it()       lcd_cmd( 0x02 )
  52. #define line_2()        lcd_cmd( 0xC0 ) // (0xC0)

Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: AKENAFAB en 30 de Diciembre de 2007, 20:09:14


Vaya  :shock: tremenda tarjetota, me he quedado boquiabierto.

Envidia de la buena   :mrgreen:

Sigo este hilo que me interesa entrarle a los dspic, solo que no ando muy bien con el CCS , no he practicado de lleno.

Saludos.

 Atentamente
   Akenafab
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: RedPic en 01 de Enero de 2008, 14:36:04
Y como consecuencia lógica e irrefrenable he montado una combinación de dos de los ejemplos anteriores: La USART y el LCD. Este ejemplo "oye" la USART y lo que recibe lo coloca en el PORTA, lo devuelve por la misma USART como eco y lo coloca en el LCD en la segunda línea a partir del carácter prompt ">". Si se completa totalmente esa segunda línea del LCD la limpia y comienza de nuevo desde el segundo carácter de la segunda linea del LCD.  :mrgreen:

(http://picmania.garcia-cuervo.net/images/explorer-16_microchip_11.jpg)

(http://picmania.garcia-cuervo.net/images/explorer-16_microchip_11_dump_uart.jpg)

Código: C#
  1. /**********************************************************************
  2. * © 2008 PicManía By RedRaven
  3. *        http://picmania.garcia-cuervo.net
  4. *
  5. * FileName:        main_LCD_USART.c
  6. * Dependencies:    p33FJ256GP710.h
  7. * Processor:       dsPIC33F
  8. * Compiler:        MPLAB® C30 v2.01 or higher
  9. *
  10. * When recive USART present in LCD
  11. *
  12. * C30 Optimization Level: -O1
  13. *
  14. **********************************************************************/
  15.  
  16. #include "p33FJ256GP710.h"
  17. #include "lcd.h"
  18.  
  19. _FOSCSEL(FNOSC_FRC);
  20. _FOSC(FCKSM_CSECMD & OSCIOFNC_OFF  & POSCMD_NONE);
  21.  
  22. _FWDT(FWDTEN_OFF);
  23.  
  24. unsigned int  flag_RECUSART;
  25. unsigned char CHAR_RECUSART;
  26.  
  27. void __attribute__ ((interrupt, no_auto_psv)) _U2RXInterrupt(void){
  28.        
  29.         CHAR_RECUSART = U2RXREG;
  30.         flag_RECUSART =1;
  31.         IFS1bits.U2RXIF = 0;
  32. }
  33. void __attribute__ ((interrupt, no_auto_psv)) _U2TXInterrupt(void){
  34.         IFS1bits.U2TXIF = 0;
  35. }
  36.  
  37. void InitClock() {
  38.         PLLFBD                          = 38;   // M  = 40
  39.         CLKDIVbits.PLLPOST      = 0;    // N1 =  2
  40.         CLKDIVbits.PLLPRE       = 0;    // N2 =  2
  41.         OSCTUN                          = 0;
  42.         RCONbits.SWDTEN         = 0;
  43.         // Clock switch to incorporate PLL
  44.         __builtin_write_OSCCONH(0x01);
  45.         __builtin_write_OSCCONL(0x01);
  46.         while(OSCCONbits.LOCK != 1) {};
  47. }
  48.  
  49. void InitUART2() {
  50.         // This is an EXAMPLE, so brutal typing goes into explaining all bit sets
  51.         // The HPC16 board has a DB9 connector wired to UART2, so we will
  52.         // be configuring this port only
  53.         // configure U2MODE
  54.         U2MODEbits.UARTEN = 0;  // Bit15 TX, RX DISABLED, ENABLE at end of func
  55.         //U2MODEbits.notimplemented;    // Bit14
  56.         U2MODEbits.USIDL  = 0;  // Bit13 Continue in Idle
  57.         U2MODEbits.IREN   = 0;  // Bit12 No IR translation
  58.         U2MODEbits.RTSMD  = 0;  // Bit11 Simplex Mode
  59.         //U2MODEbits.notimplemented;    // Bit10
  60.         U2MODEbits.UEN    = 0;  // Bits8,9 TX,RX enabled, CTS,RTS not
  61.         U2MODEbits.WAKE   = 0;  // Bit7 No Wake up (since we don't sleep here)
  62.         U2MODEbits.LPBACK = 0;  // Bit6 No Loop Back
  63.         U2MODEbits.ABAUD  = 0;  // Bit5 No Autobaud (would require sending '55')
  64.         U2MODEbits.URXINV = 0;  // Bit4 IdleState = 1  (for dsPIC)
  65.         U2MODEbits.BRGH   = 0;  // Bit3 16 clocks per bit period
  66.         U2MODEbits.PDSEL  = 0;  // Bits1,2 8bit, No Parity
  67.         U2MODEbits.STSEL  = 0;  // Bit0 One Stop Bit
  68.         // Load a value into Baud Rate Generator.  Example is for 9600.
  69.         // See section 19.3.1 of datasheet.
  70.         //  U2BRG = (Fcy/(16*BaudRate))-1
  71.         //  U2BRG = (37M/(16*9600))-1
  72.         //  U2BRG = 240
  73.         U2BRG = 240;            // 40Mhz osc, 9600 Baud
  74.         // Load all values in for U1STA SFR
  75.         U2STAbits.UTXISEL1 = 0; //Bit15 Int when Char is transferred (1/2 config!)
  76.         U2STAbits.UTXINV   = 0; //Bit14 N/A, IRDA config
  77.         U2STAbits.UTXISEL0 = 0; //Bit13 Other half of Bit15
  78.         //U2STAbits.notimplemented = 0; //Bit12
  79.         U2STAbits.UTXBRK   = 0; //Bit11 Disabled
  80.         U2STAbits.UTXEN    = 0; //Bit10 TX pins controlled by periph
  81.         U2STAbits.UTXBF    = 0; //Bit9 *Read Only Bit*
  82.         U2STAbits.TRMT     = 0; //Bit8 *Read Only bit*
  83.         U2STAbits.URXISEL  = 0; //Bits6,7 Int. on character recieved
  84.         U2STAbits.ADDEN    = 0; //Bit5 Address Detect Disabled
  85.         U2STAbits.RIDLE    = 0; //Bit4 *Read Only Bit*
  86.         U2STAbits.PERR     = 0; //Bit3 *Read Only Bit*
  87.         U2STAbits.FERR     = 0; //Bit2 *Read Only Bit*
  88.         U2STAbits.OERR     = 0; //Bit1 *Read Only Bit*
  89.         U2STAbits.URXDA    = 0; //Bit0 *Read Only Bit*
  90.         IPC7 = 0x4400;                  //Mid Range Interrupt Priority level, no urgent reason
  91.         IFS1bits.U2TXIF    = 0; //Clear the Transmit Interrupt Flag
  92.         IEC1bits.U2TXIE    = 1; //Enable Transmit Interrupts
  93.         IFS1bits.U2RXIF    = 0; //Clear the Recieve Interrupt Flag
  94.         IEC1bits.U2RXIE    = 1; //Enable Recieve Interrupts
  95.         U2MODEbits.UARTEN  = 1; //And turn the peripheral on
  96.         U2STAbits.UTXEN = 1;
  97. }
  98.  
  99. void putUART2( char c){
  100.         while ( U2STAbits.UTXBF); // wait while Tx buffer full
  101.         U2TXREG = c;
  102. }
  103.  
  104. void putsUART2( char *s){
  105.         unsigned int i=0;
  106.         while(s[i])             // loop until *s == ‘\0’, end of string
  107.                 putUART2(s[i++]);       // send the character and point to the next one
  108. }
  109.  
  110. int main(void){
  111.  
  112.         char mytext1[] = "dsPIC33F-PCtoLCD";
  113.         char mytext2[] = ">               ";
  114.     char *pText1=&mytext1[0];
  115.     char *pText2=&mytext2[0];
  116.         unsigned int nCHARS=0;
  117.  
  118.        
  119.         TRISA = 0x0000; // All to output
  120.         InitClock();    // This is the PLL settings
  121.         InitUART2();    // Initialize UART2 for 9600,8,N,1 TX/RX
  122.         Init_LCD();             // Initialize LCD
  123.         // Send to serial
  124.         putsUART2(mytext1);
  125.         putsUART2("\r\n");
  126.         // Hellow World message
  127.         home_clr();
  128.         puts_lcd(pText1,sizeof(mytext1)-1);
  129.         line_2();
  130.         puts_lcd(pText2,sizeof(mytext2)-1);
  131.         line_2();
  132.         cursor_right();
  133.     // Infinite Loop
  134.         flag_RECUSART = 0;
  135.     while(1){
  136.                 if(flag_RECUSART==1){
  137.                         flag_RECUSART=0;
  138.                         LATA = CHAR_RECUSART;     // Lo que recibo vía UART2 lo pongo en el PORTA ...
  139.                         putUART2(CHAR_RECUSART);  // ... lo devuelvo como eco ...
  140.                         lcd_data(CHAR_RECUSART);  // ... y lo pongo en el LCD
  141.                         if(++nCHARS==15){
  142.                                 line_2();
  143.                                 puts_lcd(pText2,sizeof(mytext2)-1);
  144.                                 line_2();
  145.                                 cursor_right();
  146.                                 nCHARS=0;
  147.                         }
  148.                 }
  149.         };
  150. }
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: Renatox_ en 01 de Enero de 2008, 16:29:22
El CCS y el C30 tienen algo en comun que es la forma de configurar los bits, eso es bueno.

como esto:

U2MODEbits.UEN    = 0;   // Bits8,9 TX,RX enabled, CTS,RTS not

suerte con los dspic, estás aprendiendo rápido.

un saludo;
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: RedPic en 01 de Enero de 2008, 16:49:06
Si, menos dá una piedra y algo es algo. Pero la verdad es que es mucho mas dificil ya que le faltan las funciones de alto nivel que tiene el CCS C. Y se juntan el hambre con las ganas de comer, los dsPIC tienen muchísimos mas registros de configuración, y por ende muchos mas bits, y al no tener las funciones de alto nivel hay que configurar docenas de bits para hacer que algo funcione.

El ejemplo mas espectacular que he visto hasta ahora es el de la USART. En CCS C se soluciona con una línea, en el C30 hay que escribir un kbyte de texto con la configuración:

CCS C

Código: C#
  1. #use rs232(baud=115200, xmit=RC6, rcv=RC7, ERRORS)

C30

Código: C#
  1. void InitUART2() {
  2.  
  3.         U2MODEbits.UARTEN = 0;  // Bit15 TX, RX DISABLED, ENABLE at end of func
  4.         //U2MODEbits.notimplemented;    // Bit14
  5.         U2MODEbits.USIDL  = 0;  // Bit13 Continue in Idle
  6.         U2MODEbits.IREN   = 0;  // Bit12 No IR translation
  7.         U2MODEbits.RTSMD  = 0;  // Bit11 Simplex Mode
  8.         //U2MODEbits.notimplemented;    // Bit10
  9.         U2MODEbits.UEN    = 0;  // Bits8,9 TX,RX enabled, CTS,RTS not
  10.         U2MODEbits.WAKE   = 0;  // Bit7 No Wake up (since we don't sleep here)
  11.         U2MODEbits.LPBACK = 0;  // Bit6 No Loop Back
  12.         U2MODEbits.ABAUD  = 0;  // Bit5 No Autobaud (would require sending '55')
  13.         U2MODEbits.URXINV = 0;  // Bit4 IdleState = 1  (for dsPIC)
  14.         U2MODEbits.BRGH   = 0;  // Bit3 16 clocks per bit period
  15.         U2MODEbits.PDSEL  = 0;  // Bits1,2 8bit, No Parity
  16.         U2MODEbits.STSEL  = 0;  // Bit0 One Stop Bit
  17.         // Load a value into Baud Rate Generator.  Example is for 9600.
  18.         U2BRG = 240;            // 40Mhz osc, 9600 Baud
  19.         // Load all values in for U1STA SFR
  20.         U2STAbits.UTXISEL1 = 0; //Bit15 Int when Char is transferred (1/2 config!)
  21.         U2STAbits.UTXINV   = 0; //Bit14 N/A, IRDA config
  22.         U2STAbits.UTXISEL0 = 0; //Bit13 Other half of Bit15
  23.         //U2STAbits.notimplemented = 0; //Bit12
  24.         U2STAbits.UTXBRK   = 0; //Bit11 Disabled
  25.         U2STAbits.UTXEN    = 0; //Bit10 TX pins controlled by periph
  26.         U2STAbits.UTXBF    = 0; //Bit9 *Read Only Bit*
  27.         U2STAbits.TRMT     = 0; //Bit8 *Read Only bit*
  28.         U2STAbits.URXISEL  = 0; //Bits6,7 Int. on character recieved
  29.         U2STAbits.ADDEN    = 0; //Bit5 Address Detect Disabled
  30.         U2STAbits.RIDLE    = 0; //Bit4 *Read Only Bit*
  31.         U2STAbits.PERR     = 0; //Bit3 *Read Only Bit*
  32.         U2STAbits.FERR     = 0; //Bit2 *Read Only Bit*
  33.         U2STAbits.OERR     = 0; //Bit1 *Read Only Bit*
  34.         U2STAbits.URXDA    = 0; //Bit0 *Read Only Bit*
  35.         IPC7 = 0x4400;                  //Mid Range Interrupt Priority level, no urgent reason
  36.         IFS1bits.U2TXIF    = 0; //Clear the Transmit Interrupt Flag
  37.         IEC1bits.U2TXIE    = 1; //Enable Transmit Interrupts
  38.         IFS1bits.U2RXIF    = 0; //Clear the Recieve Interrupt Flag
  39.         IEC1bits.U2RXIE    = 1; //Enable Recieve Interrupts
  40.         U2MODEbits.UARTEN  = 1; //And turn the peripheral on
  41.         U2STAbits.UTXEN = 1;
  42. }
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: Renatox_ en 01 de Enero de 2008, 19:10:31
Hola, asi es al principio difícil. una ves que te familiarices con el hardware prederirás configurarlo bit a bit a hacerlo con las funciones del CCS, pon tus archivos config() de los módulos en un archivo C aparte para que no se te llene el archivo main.c.

Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: MGLSOFT en 01 de Enero de 2008, 21:08:37
No has probado con CCS PCD ??? :mrgreen:
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: Nocturno en 02 de Enero de 2008, 05:32:28
Don Diego, aquí está el PDF que te comenté en la cafetería.

No te vas a librar de estudiar las datasheets para configurar los periféricos, pero al menos tu código quedará más inteligible si utilizas las librerías que incorpora el C30. Aquí vienen todas explicadas, incluso las de funciones avanzadas del módulo dsp.

http://ww1.microchip.com/downloads/en/DeviceDoc/16Bit_Language_Tool_Libraries_51456d.pdf
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: RedPic en 02 de Enero de 2008, 05:37:24
Po sa'gradece Manuelo. Descargo, leo y que Dios reparta suerte.
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: blackcat en 02 de Enero de 2008, 15:30:46
De igual forma ... si notas bien ... usar la libreria de microchip para configurar cierto modulo es como hacerlo de la misma forma que poniendo todo el codigo ... ES DECIR siempre tenes que leer completamente la hoja de datos y el manual de referencia ... PERO sin duda de la manera que REDPIC lo ha venido haciendo es mejor forma de aprender a utilizar el dsPIC y es mas reconfortante porque se siente que de esa manera podes mejorar el codigo y se conoce mucho sobre la arquitectura y diseño del dsPIC ... sinceramente yo no me siento muy contento con la libreria de microchip y mas me ha servido de EJEMPLO que de aplicacion de mas alto nivel como se haria con el CCS ..

LO QUE SI RESPETO es la libreria DSP de microchip las rutinas de filtros FIR e IIR .. operaciones vectoriales, control y transformadas ... son sencillamente EXCELENTES .. el nivel de optimizacion es genial ... la precision es BUENA para tratarse de procesamiento digital pero que se podia esperar de operaciones de PUNTO FIJO

Me gusta mucho la iniciativa de REDPIC al poner buena cantidad de codigo y ejemplos claros que es lo que la mayoria de personas busca cuando se inician con la programacion en C30 .. en un proyecto tuve que desarrollar todos los modulos ( excepto el ECAN ) y talvez un reto importante para REDPIC seria el modulo SPI utilizando DMA .... el SPI por si solo si funciono pero SPI con DMA pase dias trantando de hacerlo funcionar pero no tuve exito y no me quedo remedio que dejarlo COLGADO porque ya se me estaba complicando la situacion y necesitaba avanzar en el proyecto ...

Yo no se que es lo que pasa pero lo que son la comunicaciones I2C y SPI de microchip nunca funcionan como deberia ser ...

Saludos!!


 
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: RedPic en 02 de Enero de 2008, 18:00:04
Muchas gracias Blackcat por tus palabras. Es que a mi siempre me gusta hacer eso ... empezar desde cero e ir posteando uno a uno las pruebas, experimentos y pequeños avances que consigo. Así quien desee empezar tiene algo a lo que sujetarse y no tiene que tirarse de cabeza a una piscina que no sabe si tiene agua. Desde que empecé con el primer 16F628 de hace tres años a este dsPIC de ahora siempre he actuado de la misma forma.  :mrgreen:

P.D. El DMA en donde SPI ... todo se andará. Ja, ja, ja  :D :D :D
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: Nocturno en 02 de Enero de 2008, 18:04:26
Yo hice un ejemplo de utilización del SPI por DMA. Lo tengo en alguna parte; en cuanto encuentre lo traigo al foro, pero a otro hilo para no guarrearle este hilo al amigo Diego.
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: RedPic en 02 de Enero de 2008, 18:22:00
Mu bien Manolo, se agradece.

Acabo de desempaquetar el paquete (otra cosa que no sea un paquete no se puede ni debe desempaquetar) que contiene la Graphics PICTail Plus Board con su preciosa Touch Screen cubierta del pertinente velo protector, he descargado e instalado la Microchip Graphics Library .... y ¡Oh, cielos! en la primera linea de la ayuda leo que "This version of the library only supports PIC24F Family."

Atención Blackcat, pregunta: ¿Tu tienes un PIC24 para las pruebas? o ¿se puede compilar para un dsPIC33? Dí que sí, dí que sí ... por favor ....  :shock: :shock: :shock:


Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: RedPic en 02 de Enero de 2008, 18:33:17
Hoy estoy espeso. Eso de haber vuelto de mis vacaciones de Navidad no me ha sentado nada bien.

Blackcat, yo solo me contesto con lo que tu pusiste en tu post con las fotografias: Solo está por ahora para los PIC's 24H

Mi susto ha sido al creer que tenía que esperar ahora a pedir un PIC24 con su socket ... y resulta que el primer programa que compilé y que creía un dsPIC era en realidad un PIC24. Que también lo trae la Explorer 16.

Lo dicho, que hoy estoy espeso.  :mrgreen: :mrgreen: :mrgreen:

Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: blackcat en 02 de Enero de 2008, 22:52:32
El explorer 16 si recuerdo bien ... viene con dos micros un 33 y un 24

El C30 sirve para todos los 24, 30 y 33 ... por suerte!

Lastima que la libreria de graficos solo es para 24 porque yo utilizo mas 33F  que 24, ahora si:

Libreria de graficos + DSP + RTOS = seria lo mejor que puede pasar en mi vida ... Aunque podria utilizar el 24F solo como soporte grafico y el 33F como la unidad central y utilizar la comunicacion I2C como bus de comunicacion, pero eso involucra dos micros y no me suena muy bonita la idea  :( espero que cuando llegue mis vacaciones ya exista una version si no ... se va de esa manera..

Por eso estoy ansioso que microchip lance la libreria de graficos para 33F, por ahi hay otras "marcas" gratuitas que tienen sus propias funciones para el manejo de pantallitas de ese tipo, pero solo encontre una y soporta pantallas monocromaticas o hace funciones solo monocromaticas por ser gratuita; con colores hay que $$$ ...

Trate de publicar las funciones SPI que tengo con DMA pero se me hizo un enredo  :? pues eso lo programe ya hace varios meses y la verdad las funciones estan tan desordenadas que mejor las vuelvo hacer .. pues estoy utilizando un RTOS para aprovechar los tiempos de espera en que el PIC dura enviando y recibiendo datos ...

Saludos!
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: Nocturno en 03 de Enero de 2008, 04:12:43
¿Y no crees que funcionará también con el 33F?. A priori no veo diferencias entre un pic 24H y un 33F exceptuando el módulo dsp.
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: blackcat en 03 de Enero de 2008, 16:26:30
Algunos 24 tienen un puerto paralelo ( PMP ) que es por donde se conecta la pantallita, me imagino que las libreria esta hecha para usar ese modulo  ... pero sinceramente no he leido bien al respecto ...

Habria que ver como se puede emular el PMP en un 33F ... eso seria  muy ingenieril!  :D :D

Lo que tenia pensado era hacer algo tipo reproductor MP3 pero ya con display ... pero queria aprovechar las caracteristicas DSP del 33F para crear ecualizadores digitales, efectos, etc ... pensandolo bien se oye complicado pero con un RTOS las cosas se ponen mucho mas faciles

Seria un proyecto muy bonito  :g)  ... y bastante retador!
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: PalitroqueZ en 03 de Enero de 2008, 16:34:25
Hey Diego ¿seria posible ver una imagen del ICD2? siempre veo el cartón redondo con el simbolo de microchip y no se como es el aparato.  :?



Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: MGLSOFT en 03 de Enero de 2008, 16:44:28
Si ordenas las letras de Palitroques, leeras Destripalo... :D :D
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: PalitroqueZ en 03 de Enero de 2008, 16:48:45
Si ordenas las letras de Palitroques, leeras Destripalo... :D :D

jaja no me había dado cuenta  :D

Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: MGLSOFT en 03 de Enero de 2008, 16:53:48
O, que lo destripez !!

Je..je..es broma, a ver si pica Diego !! :D :D
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: blackcat en 03 de Enero de 2008, 16:55:59
El ICD2 es como una galleta de 9.5cm de diametro y 2.3cm de grueso ...

Es una herramienta bastante util .. se acopla bastante bien al MPLAB permite programar y hacer debug en ALGUNOS micros .. no todos pero si la mayoria

El debug permite hasta 4 breakpoints y te permite visualizar todos los registros del micro ...

(http://img152.imageshack.us/img152/8579/dsc03569ob3.jpg)
(http://img218.imageshack.us/img218/4825/dsc03567gh8.jpg)
(http://img152.imageshack.us/img152/1435/dsc03568lg8.jpg)

Hay un accesorio que sirve como base para programar ALGUNOS micros de encapsulado DIP

(http://img248.imageshack.us/img248/8899/dsc03576ha5.jpg)


Por cierto esa forma redonda lo hace bastante incomodo ... para transportar o cuando hay que acomodarlo en la mesa de trabajo


Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: RedPic en 03 de Enero de 2008, 17:29:41
Y el ICD2 tiene una cosa que he utilizado muchísimo programando en Borland Delphi. Cuando pones un Breakpoint y el programa se para (indicándolo con una flecha verde en la instrucción en la que se ha detenido) puedes ver el valor en ese momento de cualquier variable con solo poner encima el puntero del ratón.  :mrgreen:
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: blackcat en 03 de Enero de 2008, 17:53:12
Algo muy importante ...

Sin embargo, en MODO DEBUGGER he notado que cuando existe algun error .. el mas tipico .. escribir en la posicion de un array que no existe ... digamos el array:

int arreglo[20];

un arreglo de 20 posiciones ( 0 - 19 )  de datos integer, si por alguna razon ( obviamente de error humano  :mrgreen: ) escribimos en la posicion 20 eso detiene la ejecucion de codigo, pero el MPLAB no dice en donde se produjo el error! de hecho no dice que hubo error simplemente se detiene y no aparece la flecha verde ... una forma sencilla de detectar errores es conociendo el ultimo valor del PC ( program counter ) pero no se de que forma saber cual fue el ultimo valor del PC pues si se lee del WATCH despues del error este sale con el valor 0 ..

Si el programa es corto es facil detectarlo ... pero si el programa ocupa ya mas de 20kbytes .. es muy dificil ...

Otra forma de depurarcion es la ejecucion paso a paso... pero eso es muy lento

La cosa se pone mucho mas complicada  cuando el codigo no es escrito por uno.. que se yo ... el codigo del RTOS o de alguna libreria .. ahi uno queda con la duda si el error es del codigo ajeno o del codigo propio ...



Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: RedPic en 03 de Enero de 2008, 17:59:47
Ja, ja, ja  :D :D :D

O como me pasó a mí: que me pasé un par de horas diciendo que el MPLAB, el ICD2 y todo Microchip eran una mierda del tamaño de una catedral porque los valores que me daba de las variables eran simplemente imposibles ... hasta que me dí cuenta que había puesto los Breakpoints y seleccionado el DEBUGGER ICD2 ¡¡¡ Sin compilar el programa en modo DEBUG sino en RELEASE !!!  :oops:

Conclusión: La mierda era evidentemente yo, no Microchip.

Ja, ja, ja  :D :D :D


Por cierto, ya he compilado y ejecutado el ejemplo "gordo" de las librerías gráficas y es una verdadera pasada de buena.  :mrgreen: :mrgreen: :mrgreen:
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: blackcat en 03 de Enero de 2008, 18:17:35
Si ese ejemplo dura rato bajando al pic !!  :-/ :-/

Aunque varias veces yo he dejado RELEASE cuando hago debug al dspic ( se me olvida cambiarlo ) ... y me ha funcionado bien ... pero hay veces que hasta reiniciar la compu para poder leer los registros ... :x :x
 
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: RedPic en 03 de Enero de 2008, 18:26:16
 :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen:

(http://picmania.garcia-cuervo.net/images/EXPLORER-16 Microchip 12 Graphics PICTail Board TODOPIC.JPG)
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: blackcat en 03 de Enero de 2008, 19:01:30
QUE BUENA FOTO!!!

EXCELENTE
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: Nocturno en 03 de Enero de 2008, 19:07:58
Pero cómo te diviertes, jodío
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: MGLSOFT en 03 de Enero de 2008, 19:21:38
MERDAVILLOSO !!!
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: PalitroqueZ en 04 de Enero de 2008, 14:39:14
aclarado entonces blackcat  :mrgreen:

Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: RedPic en 05 de Enero de 2008, 12:25:25
Buenoooo, creo que voy empezando a comprender la Librería Gráfica de la gente de Microchip. Y me gusta. Se parece mucho a las LeadTools que utilizaba en Delphi, la filosofía es muy parecida. Y además el Copy/Paste con los ejemplos que trae hacen maravillas para poder montar un proyecto nuevo.

El caso es que he abierto un proyecto desde cero y he intentado montar un ejemplito fácil pero que me hiciese ver qué es lo que me hacía falta, para ir añadiéndolo al proyecto, y en qué orden. Digamos que el cuerpo base es el del ejemplo "Graphics AN1136" de donde he sacado la configuración general y el tratamiento de un simple Buttom. Del ejemplo "Graphics Primitive Layer Demo" he sacado el tratamiento de Fonts del texto y por último del "Graphics Object Layer Demo" el tema del Beep cuando pulso sobre el botón.

Así he montado un programa que: Coloca un texto de cabecera al inicio a modo de presentación, crea un Botón en la posición, con el tamaño y el texto que yo deseo. Al pulsar sobre el Botón emite un Beep, incrementa una variable y muestra su valor en el centro de la pantalla con otro tipo y color distintos de la letra.

Además me he saltado a la torera una de las prescripciones que venían en la Ayuda de la Librería Gráfica, y que decía dónde tenía que poner el proyecto para que funcionasen los includes, las librerías y todo eso ... Y lo he colocado en MI directorio de proyectos, a un kilómetro de donde me decían que tenia que poner todo. Me ha costado un poco de trabajo configurar todo el tema de los direcorios de includes y eso pero al final ha funcionado correctamente.

El resultado: Un pequeño paso para la Humanidad pero un salto gigantesco para mí.  :mrgreen:

(http://picmania.garcia-cuervo.net/images/EXPLORER-16 Microchip 13 Graphics PICTail Board Test1.JPG)

El programa entonces ha quedado así:

Código: C#
  1. /*****************************************************************************
  2.  * © 2008 PicManía By RedRaven
  3.  *        http://picmania.garcia-cuervo.net
  4.  *
  5.  * FileName:        Test1.c
  6.  * Dependencies:    Test1.h
  7.  * Processor:       PIC24FJ128GA010
  8.  * Compiler:            MPLAB C30 V3.00
  9.  * Linker:          MPLAB LINK30
  10.  *
  11.  * Coloca un texto de cabecera. Crea un Botón.
  12.  * Al pulsar sobre el Botón emite un Beep,
  13.  * incrementa una variable y muestra su valor
  14.  * en el centro de la pantalla
  15.  *****************************************************************************/
  16.  
  17. #include "Test1.h"
  18. #include <stdio.h>
  19.  
  20. // Configuration bits
  21. _CONFIG2(FNOSC_PRIPLL & POSCMOD_XT) // Primary XT OSC with PLL
  22. _CONFIG1(JTAGEN_OFF & FWDTEN_OFF)   // JTAG off, watchdog timer off
  23.  
  24. ///////////////////////////////// FONTS ///////////////////////////////////////
  25. extern FONT_FLASH Font35;
  26.  
  27. /////////////////////////////////////////////////////////////////////////////
  28. //                              OBJECT'S IDs
  29. /////////////////////////////////////////////////////////////////////////////
  30.  
  31. #define ID_BTN1             10
  32.  
  33. /////////////////////////////////////////////////////////////////////////////
  34. //                            LOCAL PROTOTYPES
  35. /////////////////////////////////////////////////////////////////////////////
  36. void Present_Me(void);
  37. void Monitor_Value(void);
  38. void CheckCalibration(void);            // check if calibration is needed
  39.  
  40. /////////////////////////////////////////////////////////////////////////////
  41. //                                  MAIN
  42. /////////////////////////////////////////////////////////////////////////////
  43. GOL_SCHEME      *altScheme;                 // alternative style scheme
  44. WORD            update = 0;                                 // variable to update customized graphics
  45. unsigned int Value    = 0;
  46. unsigned int antValue = 0;
  47.  
  48. int main(void){
  49.  
  50.         GOL_MSG msg;                                    // GOL message structure to interact with GOL
  51.  
  52.     EEPROMInit();                                       // initialize EEPROM
  53.     TouchInit();                                        // initialize touch screen
  54.     BeepInit();                                         // Initialize beeper
  55.         GOLInit();                                              // initialize graphics library &
  56.                                                                         // create default style scheme for GOL
  57.     SetColor(BLACK);
  58.     ClearDevice();
  59.  
  60.         Present_Me();
  61.  
  62.     altScheme = GOLCreateScheme();              // create alternative style scheme
  63.     altScheme->TextColor0 = BLACK;
  64.     altScheme->TextColor1 = WHITE;
  65.  
  66.         BtnCreate(      ID_BTN1,                                // object’s ID
  67.                                 10,  50,                        // object’s Top Left Corner  
  68.                                 110,100,                                // object’s Bottom Right Corner
  69.                 0,                      // radius of the rounded edge
  70.                                 BTN_DRAW,                               // draw the object after creation
  71.                                 NULL,                                   // no bitmap used
  72.                                 "One ++",                               // use this text
  73.                                 altScheme);                             // use alternative style scheme
  74.  
  75.         update = 1;                                                     // to initialize the user graphics
  76.  
  77.         while(1){
  78.         if(GOLDraw()) {                                 // Draw GOL object
  79.                 TouchGetMsg(&msg);              // Get message from touch screen
  80.                 GOLMsg(&msg);                   // Process message
  81.         }      
  82.     }
  83. }
  84.  
  85. void Present_Me(void){
  86.  
  87.         static const char text[] = "'One Beep Button' by PicMania";
  88.  
  89.     SetFont(&FONTDEFAULT);
  90.     SetColor(BRIGHTRED);
  91.         MoveTo(0,0);
  92.     while(!OutText((char*) text));
  93. }
  94.  
  95. void Monitor_Value(void){
  96.  
  97.         static char text[6];
  98.  
  99.         // Delete ant Text
  100.         sprintf(text,"%4d",antValue);
  101.         MoveTo(150,110);
  102.     SetFont(&Font35);
  103.         SetColor(altScheme->TextColor0);
  104.     while(!OutText((char*) text));
  105.         // Print act Text
  106.         sprintf(text,"%4d",Value);
  107.         MoveTo(150,110);
  108.         SetColor(altScheme->TextColor1);
  109.     while(!OutText((char*) text));
  110. }
  111.  
  112.  
  113. /////////////////////////////////////////////////////////////////////////////
  114. // Function: WORD GOLMsgCallback(WORD objMsg, OBJ_HEADER* pObj, GOL_MSG* pMsg)
  115. // Input: objMsg - translated message for the object,
  116. //        pObj - pointer to the object,
  117. //        pMsg - pointer to the non-translated, raw GOL message
  118. // Output: if the function returns non-zero the message will be processed by default
  119. // Overview: it's a user defined function. GOLMsg() function calls it each
  120. //           time the valid message for the object received
  121. /////////////////////////////////////////////////////////////////////////////
  122. WORD GOLMsgCallback(WORD objMsg, OBJ_HEADER* pObj, GOL_MSG* pMsg){
  123.  
  124.         WORD objectID;
  125.        
  126.     objectID = GetObjID(pObj);
  127.        
  128.         if (objectID == ID_BTN1) {
  129.                 if (objMsg == BTN_MSG_PRESSED) {        // check if button is pressed
  130.                         antValue=Value;
  131.                         ++Value;
  132.                         Beep();
  133.                 }
  134.                 else {
  135.                 }
  136.                 update = 1;
  137.         }
  138.        
  139.         return 1;
  140. }
  141.  
  142. /////////////////////////////////////////////////////////////////////////////
  143. // Function: WORD GOLDrawCallback()
  144. // Output: if the function returns non-zero the draw control will be passed to GOL
  145. // Overview: it's a user defined function. GOLDraw() function calls it each
  146. //           time when GOL objects drawing is completed. User drawing should be done here.
  147. //           GOL will not change color, line type and clipping region settings while
  148. //           this function returns zero.
  149. /////////////////////////////////////////////////////////////////////////////
  150. WORD GOLDrawCallback(){
  151.  
  152.     if(update){
  153.                 Monitor_Value();
  154.                 update = 0;
  155.         }
  156.  
  157.         return 1;                              
  158. }
  159.  
  160. void CheckCalibration(void)                  // Check if calibration is needed
  161. {
  162.     // If S3 button on Explorer 16 board is pressed calibrate touch screen
  163.     if(PORTDbits.RD6 == 0){
  164.         TouchCalibration();
  165.         TouchStoreCalibration();
  166.     }
  167.     // If it's a new board (version byte in EEPROM has different Value) calibrate touch screen
  168.     if(GRAPHICS_LIBRARY_VERSION != EEPROMReadWord(EEPROM_VERSION)){
  169.             // Show in LED D3 that touch screen is not calibrated
  170.             TRISAbits.TRISA0 = 0;
  171.             LATAbits.LATA0   = 1;
  172.         TouchCalibration();
  173.         TouchStoreCalibration();
  174.         EEPROMWriteWord(GRAPHICS_LIBRARY_VERSION,EEPROM_VERSION);
  175.             // Show in LED D3 that touch screen is calibrated
  176.             TRISAbits.TRISA0 = 0;
  177.             LATAbits.LATA0   = 0;
  178.     }
  179.     // Load touch screen calibration parameters from EEPROM
  180.     TouchLoadCalibration();
  181. }

Y los includes y demás son estos (copio la pantalla del Proyecto en MPLAB):

(http://picmania.garcia-cuervo.net/images/EXPLORER-16 Microchip 13 Graphics PICTail Board Test1 Includes.jpg)



Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: MGLSOFT en 05 de Enero de 2008, 20:12:24
Buenisimo!! :-/
Felicitaciones por los avances!! :lol:
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: RedPic en 06 de Enero de 2008, 12:37:10
Otro paso adelante.

Quien pone un botón pone ciento. así que me he hecho ya el Test2.c que pone en pantalla un KEYPAD con los 10 números, del "0" al "9", y otros dos mas con "Si" y "No". Las dos lineas superiores están destinadas a Texto, la primera de ellas a un texto fijo y la segunda para presentar mensajes. Al pulsar cada uno de los botones se van acumulando sobre un string que se presenta en la segunda línea de texto, la de los mensajes.  :mrgreen:

Los detalles interesantes de este ejemplo son:

La función Create_Objects() crea on-the-fly los botones, en función de los parámetros definidos con KEYPAD_BTN, NUMVERSPC, NUMHORBTN y NUMVERBTN. Lo único importante a tener en cuenta es que los Textos que aparecen en cada botón tienen que ser contantes ó variables estáticas diferenciadas, yo he utilizado la matriz de constantes BtnTexts, cuando lo intenté creando un string que iba cambiando según creaba cada uno de los botones me aparecían todos con el ultimo contenido del string.

La función GOLMsgCallback() es llamada cada vez que se produce un "evento". Ahí es donde preguntamos por el objeto que produce el evento, a través de su objectID y el tipo de evento producido, en nuestro caso "interceptamos" el tipo BTN_MSG_PRESSED y con él vamos cargando el string de salida MyText[]. Cada vez que tenemos un evento válido nuevo ponemos en alto un flag llamado update.

La función GOLDrawCallback() es llamada por la librería cada vez que tiene que actualizar la pantalla. En ella detectamos si tenemos el flag update en alto y en caso de ser así ponemos el string MyText[] en la pantalla.

Ea, seguimos para bingo.

Código: C#
  1. /*****************************************************************************
  2.  * © 2008 PicManía By RedRaven
  3.  *        http://picmania.garcia-cuervo.net
  4.  *
  5.  * FileName:        Test2.c
  6.  * Dependencies:    Test2.h
  7.  * Processor:       PIC24FJ128GA010
  8.  * Compiler:            MPLAB C30 V3.00
  9.  * Linker:          MPLAB LINK30
  10.  *
  11.  * Matriz de botones numericos + función.
  12.  * Area de Textos fijos
  13.  * Area de Mensajes con lo pulsado en el KEYPAD
  14.  *****************************************************************************/
  15.  
  16. #include "Test2.h"
  17. #include <stdio.h>
  18.  
  19. // Configuration bits
  20. _CONFIG2(FNOSC_PRIPLL & POSCMOD_XT) // Primary XT OSC with PLL
  21. _CONFIG1(JTAGEN_OFF & FWDTEN_OFF)   // JTAG off, watchdog timer off
  22.  
  23. ///////////////////////////////// FONTS ///////////////////////////////////////
  24. extern FONT_FLASH Font25;
  25. extern FONT_FLASH Font35;
  26.  
  27. /////////////////////////////////////////////////////////////////////////////
  28. //                              OBJECT'S IDs & DIMENSIONS
  29. /////////////////////////////////////////////////////////////////////////////
  30.  
  31. #define KEYPAD_BTN      10
  32. #define NUMVERSPC       1
  33. #define NUMHORBTN       4
  34. #define NUMVERBTN       3
  35.  
  36. /////////////////////////////////////////////////////////////////////////////
  37. //                            LOCAL PROTOTYPES
  38. /////////////////////////////////////////////////////////////////////////////
  39. void Create_Objects(void);
  40. void CheckCalibration(void);            // check if calibration is needed
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. //                                  MAIN
  44. /////////////////////////////////////////////////////////////////////////////
  45. GOL_SCHEME      *altScheme;                                     // alternative style scheme
  46. WORD            update          = 0;                    // variable to update customized graphics
  47. static char MyText[32]  = "\0";
  48. WORD        nextChar    = 0;
  49. static const char BtnTexts[12][3] = {"1","2","3","Si","4","5","6","0","7","8","9","No"};
  50.  
  51. int main(void){
  52.  
  53.     GOL_MSG msg;                                        // GOL message structure to interact with GOL
  54.  
  55.     EEPROMInit();                                       // initialize EEPROM
  56.     TouchInit();                                        // initialize touch screen
  57.     BeepInit();                                         // Initialize beeper
  58.     GOLInit();                                          // initialize graphics library &
  59.                                                                         // create default style scheme for GOL
  60.     SetColor(BLACK);
  61.     ClearDevice();
  62.     Create_Objects();
  63.  
  64.     while(1){
  65.         if(GOLDraw()) {                                 // Draw GOL object
  66.                 TouchGetMsg(&msg);              // Get message from touch screen
  67.                 GOLMsg(&msg);                   // Process message
  68.         }      
  69.     }
  70. }
  71.  
  72. void Create_Objects(void){
  73.  
  74.     static const char text[] = "Touch KEYPAD by RedPic";
  75.     unsigned int nbuttons,VerDiv,HorDiv;
  76.     unsigned int i,PosX,PosY,nHor;
  77.  
  78.     SetFont(&FONTDEFAULT);
  79.     SetColor(WHITE);
  80.     MoveTo(0,0);
  81.     while(!OutText((char*) text));
  82.  
  83.     altScheme = GOLCreateScheme();              // create alternative style scheme
  84.     altScheme->TextColor0 = BLACK;
  85.     altScheme->TextColor1 = WHITE;
  86.  
  87.     VerDiv = (unsigned int) GetMaxY() / (NUMVERBTN + NUMVERSPC);
  88.     HorDiv = (unsigned int) GetMaxX() / NUMHORBTN;
  89.     nbuttons = NUMHORBTN * NUMVERBTN;
  90.     PosX = 0; PosY = VerDiv;
  91.     nHor = 0;
  92.  
  93.     SetFont(&Font35);
  94.  
  95.     for(i=0;i<nbuttons;i++){
  96.         BtnCreate(KEYPAD_BTN+i,                 // object’s ID
  97.                         PosX,  PosY,            // object’s Top Left Corner  
  98.                         PosX+HorDiv,PosY+VerDiv,// object’s Bottom Right Corner
  99.                         0,                      // radius of the rounded edge
  100.                         BTN_DRAW,                               // draw the object after creation
  101.                         NULL,                                   // no bitmap used
  102.                         (char*) BtnTexts[i],            // use this text
  103.                         altScheme);                             // use alternative style scheme
  104.                 PosX += HorDiv;
  105.                 if(++nHor==NUMHORBTN){
  106.                         nHor = 0;
  107.                         PosX = 0;
  108.                         PosY += VerDiv;
  109.                 }
  110.         }
  111.         update = 1;                                                     // to initialize the user graphics
  112. }
  113.  
  114.  
  115. /////////////////////////////////////////////////////////////////////////////
  116. // Function: WORD GOLMsgCallback(WORD objMsg, OBJ_HEADER* pObj, GOL_MSG* pMsg)
  117. // Input: objMsg - translated message for the object,
  118. //        pObj - pointer to the object,
  119. //        pMsg - pointer to the non-translated, raw GOL message
  120. // Output: if the function returns non-zero the message will be processed by default
  121. // Overview: it's a user defined function. GOLMsg() function calls it each
  122. //           time the valid message for the object received
  123. /////////////////////////////////////////////////////////////////////////////
  124. WORD GOLMsgCallback(WORD objMsg, OBJ_HEADER* pObj, GOL_MSG* pMsg){
  125.  
  126.     WORD objectID;
  127.     unsigned int nbuttons;
  128.        
  129.     objectID = GetObjID(pObj);
  130.     nbuttons = NUMHORBTN * NUMVERBTN;
  131.                
  132.         if((objectID > (KEYPAD_BTN - 1)) && (objectID < (KEYPAD_BTN + nbuttons))){
  133.                 if (objMsg == BTN_MSG_PRESSED) {        // check if button is pressed
  134.                         MyText[nextChar++]=BtnTexts[objectID-KEYPAD_BTN][0];
  135.                         MyText[nextChar]  ='\0';
  136.                         Beep();
  137.                 }
  138.                 update = 1;
  139.         }
  140.  
  141.         return 1;
  142. }
  143.  
  144. /////////////////////////////////////////////////////////////////////////////
  145. // Function: WORD GOLDrawCallback()
  146. // Output: if the function returns non-zero the draw control will be passed to GOL
  147. // Overview: it's a user defined function. GOLDraw() function calls it each
  148. //           time when GOL objects drawing is completed. User drawing should be done here.
  149. //           GOL will not change color, line type and clipping region settings while
  150. //           this function returns zero.
  151. /////////////////////////////////////////////////////////////////////////////
  152. WORD GOLDrawCallback(){
  153.  
  154.     if(update){
  155.                 MoveTo(0,GetTextHeight(&FONTDEFAULT));
  156.                 OutText(MyText);
  157.                 update = 0;
  158.         }
  159.  
  160.         return 1;                              
  161. }
  162.  
  163. // End //////////////////////////////////////////////////////////////////////

(http://picmania.garcia-cuervo.net/images/EXPLORER-16 Microchip 14 Graphics Test2 KEYPAD.JPG)

Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: MGLSOFT en 06 de Enero de 2008, 12:52:07
Puedes poner marca y modelo de la pantalla y del touch pad que viene en la placa??
El touch pad usa un integrado especial para interpretarlo o lo hace el PIC??

Despues del interrogatorio apago la luz que te da en la cara... :D :D
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: AKENAFAB en 06 de Enero de 2008, 12:53:41


Que padre te ha quedado! me he quedado con los ojos pelones.

 :shock: :shock: :shock:

Felicitaciones!!

 Atentamente
   Akenafab

Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: RedPic en 06 de Enero de 2008, 13:02:21
La pantalla TFT es un SAMSUNG S6D0129 (http://www.samsung.com/global/business/semiconductor/productInfo.do?fmly_id=206&partnum=S6D0129) y es una de las cuatro o cinco que soporta la librería de Microchip.
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: MGLSOFT en 06 de Enero de 2008, 13:14:33
Ya apague la luz de interrogatorios!! :-/
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: davidpuentegrela en 06 de Junio de 2008, 05:01:30
Hola a todos.

Es la primera vez que escribo en este hilo. Por cierto RedPic, gracias por indicarme su existencia  :-)  Es muy interesante y claro.

Quería preguntarte si para la generación de las pantallas y botones, ¿lo haces por código o existe algún programilla para generarlas y luego cargarlas? Y otra duda. ¿Trabaja en bus de 8 bits con el PMP en el Puerto E o en 16 bits? Te lo pregunto porque tengo que hacer una interfaz para un módulo de control y necesito saber que puertos me quedan libres para entradas, tanto ANALG como DIG y salidas DIG del 24F
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: RedPic en 06 de Junio de 2008, 05:16:42
Todo lo hago a través de la librería Gráfica de Microchip, ella se encarga de dibujar todo, y no son imágenes cargadas que también se puede dicho sea de paso, sino "generadas" por soft. En el caso de este LCD el bus PMP de 8 bits (PMPD0..PMPD7)

Y fíjate si es a altísimo nivel:

Código: C#
  1. int main(void){
  2.    GOL_MSG msg; // GOL message structure to
  3.    // interact with GOL
  4.    TouchInit(); // Initialize touch screen
  5.    GOLInit(); // Initialize graphics library &
  6.    // create default style scheme for GOL
  7.    altScheme = GOLCreateScheme(); // Create alternative style
  8.    // scheme
  9.    altScheme->TextColor0 = BLACK; // set text color 0
  10.    altScheme->TextColor1 = BRIGHTBLUE; // set text color 1
  11.    BtnCreate( ID_BTN1, // 1st Button ID
  12.      20, 160, 150, 210, // Object's dimension
  13.      BTN_DRAW, // set state of the object:
  14.      // draw the object
  15.      NULL, // no bitmap used
  16.      "LEFT", // use this text
  17.      NULL); // use default style scheme
  18.    BtnCreate( ID_BTN2, // 2nd Button ID
  19.      170, 160, 300, 210,
  20.      BTN_DRAW,
  21.      NULL,
  22.      "RIGHT",
  23.      NULL);
  24.    SldCreate( ID_SLD1, // Slider ID
  25.      20, 105, 300, 150, // Object's dimension
  26.      SLD_DRAW, // set state of the object:
  27.      // draw the object
  28.      100, // range
  29.      5, // page
  30.      50, // initial position
  31.      NULL); // use default style scheme
  32.  
  33.    while(1){
  34.       if (GOLDraw()){ // Draw GOL object
  35.          TouchGetMsg(&msg); // Get message from
  36.          // touch screen
  37.          GOLMsg(&msg); // Process message
  38.      }
  39.    }
  40. }
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: davidpuentegrela en 06 de Junio de 2008, 05:28:40
BUFF!! Que perdido estoy... y que verde! :shock:

Pues nada a buscar App. Notes en microchip y a ver que saco...  (Con lo a gusto que estaba yo con mis 8 bits en 8051... :( )

Gracias RedPic. Empezaré a pelear un poco.
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: davidpuentegrela en 11 de Junio de 2008, 05:03:45
Hola a todos.

Redpic, estoy leyendo la datasheet del pic 24fj128ga010 y tengo una duda. ¿Estás usando para algo con la pantalla el PMA de 16 bits? No creo que la necesitas porque no se multiplexa nada y en la DSheet el ejemplo lo usa con una EEPROM. Si no la usa es una alegria pues necesito muchos pines para la aplicación que tengo que hacer (16 in digitales y 16 salidas digitales, amen de las analogicas, que las multiplexo por el circuito de adaptación de señal).

Por cierto, no se si lo sabeis, pero sagitron vende la placas de pantalla en 3'5 y 5'7 pulgadas con las librerias adaptadas para ellas.
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: davidpuentegrela en 26 de Junio de 2008, 11:40:34
Una pregunta.

Las señales del touchscreen son XL(pin RG13) XR(pin RB11) YU(pin RG14) YD(pin RB10). Los pines RB11 y RB10 son también entradas analógicas del micro. ¿El touchscreen lo gestionan de forma analógica?

Si no es así podría elegir los pines de los puertos al libre albedrío para su control ¿no?
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: RedPic en 26 de Junio de 2008, 19:15:09
Son analógicos.

Te pongo un pequeño trozo del touchscreen.c

Código: C#
  1. // Max/Min ADC values for each derection
  2. WORD _calXMin = XMINCAL;
  3. WORD _calXMax = XMAXCAL;
  4. WORD _calYMin = YMINCAL;
  5. WORD _calYMax = YMAXCAL;
  6.  
  7. // Current ADC values for X and Y channels
  8. volatile SHORT adcX     = -1;
  9. volatile SHORT adcY     = -1;
  10. volatile SHORT adcPot   = 0;
  11. volatile char  debounce_counter = 0;
  12. volatile char  calibration = 0;
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: davidpuentegrela en 30 de Junio de 2008, 05:28:45
OK. Gracias de nuevo RedPic.
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: RedPic en 18 de Agosto de 2009, 06:24:29
Por aquello del cambio de servidor (y bla, bla, bla) ... y como acabo de citar este hilo en otro sitio le he dado un repaso a todo él y he actualizado los links a las imágenes y de nuevo son visibles (que para eso están)  :mrgreen:
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: jgpeiro06 en 22 de Septiembre de 2009, 15:52:26
No se si lo conocreis o no, pero he encontrado una nueva herramienta para el MPLAB que permite crear graficamente las aplicaciones basadas en las librerias de microchip. Seguro que os ahorra mucho trabajo...

(http://www.microchip.com/stellent/groups/sitecomm_sg/documents/softwarelibrary/~export/en544475~4~snippet_layout/112480-1.gif)

Podéis descargarla de aquí:

http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2680&dDocName=en544475

Saludos
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: Nocturno en 22 de Septiembre de 2009, 15:53:52
¡Qué guay!, gracias por informar
Título: Re: Explorer 16 y QVGA: Primeros Pasos
Publicado por: fidodido18 en 10 de Junio de 2010, 16:15:19
Por aquello del cambio de servidor (y bla, bla, bla) ... y como acabo de citar este hilo en otro sitio le he dado un repaso a todo él y he actualizado los links a las imágenes y de nuevo son visibles (que para eso están)  :mrgreen:

MAESTRO SENSEI REDPIC podes colocar de nuevo los link con las imágenes?