TODOPIC
Microcontroladores PIC => Todo en microcontroladores PIC => Mensaje iniciado por: adbensi en 03 de Junio de 2006, 12:37:55
-
--------------------------------------------------------------------------------
Hola,
Estoy tieno problema con uno 18F258 con MPLAB 7.4 y C18 3.03. Lo PIC reinicia en HS-PLL4 con cristal 4MHz y 10MHz. En las outras opciones no funciona (HS,XT,RC), con diversos cristais (4MHz, 6MHz y 20MHz).
La aplicacione és simplesmeste :
#include <p18f458.h>
#include <usart.h>
#define M1_A LATAbits.LATA4
#define M1_B LATAbits.LATA5
#define M2_A LATCbits.LATC4
#define M2_B LATCbits.LATC5
void InitIO(void)
{
LATAbits.LATA4=0x00; TRISAbits.TRISA4=0x00; // M1
LATAbits.LATA5=0x00; TRISAbits.TRISA5=0x00; // M1
LATCbits.LATC4=0x00; TRISCbits.TRISC4=0x00; // M2
LATCbits.LATC5=0x00; TRISCbits.TRISC5=0x00; // M2
}
void main(void)
{
unsigned char i,buffer[64],index,vetor,pronto,MOTOR_2,MOTOR_1,SAIDA_A2,SAIDA_A1;
InitIO();
OpenUSART(USART_TX_INT_OFF &
USART_RX_INT_OFF &
USART_ASYNCH_MODE &
USART_EIGHT_BIT &
USART_CONT_RX &
USART_BRGH_HIGH,
25 );
pronto = 1;
while (1)
{
if(pronto)
{
MOTOR_1 = 'D';
MOTOR_2 = 'E';
SAIDA_A1=SAIDA_A2=255;
switch (MOTOR_1)
{
case 'E' : M1_A=0x01;M1_B=0x00;break;
case 'D' : M1_A=0x00;M1_B=0x01;break;
case 'N' : M1_A=0x00;M1_B=0x00;break;
}
switch (MOTOR_2)
{
case 'E' : M2_A=0x01;M2_B=0x00;break;
case 'D' : M2_A=0x00;M2_B=0x01;break;
case 'N' : M2_A=0x00;M2_B=0x00;break;
}
PORTA = SAIDA_A2 & 0xF0;
PORTC = (SAIDA_A2 >> 4) & 0xF0;
pronto = 0;
} // fim pronto
} // fim main
Tienes alguno problema con esso PIC? La aplicacione és correta para mi. Alguna sugestion con esso PIC?
Gracias!!
-
adbensi como están configurados los fuses? No veo que lo hayas hecho por código pero tal vez lo has hecho antes de programarlos.
Si estas simulando, te aconsejo actives los fuses por código
-
hola! :-/
Estoy ativando los fuses con MPLAB Configuration Bits:
Oscilator HS-PLL Enabled
Power UP Enabled
Todo resto disabled.
No estoy simulando :)
Acredito que exista uma falha neste microcontrolador, que talvez possa ser corrigida no compilador ou firmeware do ICD2BR.
Estou utilizando PIC18F258-I/SP E3 053032K
Com MPLAB 7.4 e C18 3.03
Utilizando ICD2BR v1.1.
Sintoma: O microcontrolador PIC18F258 trava e reinicia a todo instante, e não funciona com outro modos de configuração do oscilador (XT,HS,LP com cristais recomendados pelo datasheet) que não seja HS com PLL4 (operação máxima com cristal 10MHz). :(
Minha pesquisa na solução do problema findou com algumas dúvidas; :?
Existe uma errata da microchip para o microcontrolador citado,
Microchip PIC18FXX2 Rev. B3 Silicon Errata Sheet. :x
Alguns sistemas / suporte desenvolveram path de correção (link abaixo)
http://supp.iar.com/Support/?note=35742&from=search+result
Outros citam alternativas que não entendi como aplicar.
http://www.htsoft.com/forum/all/showthreaded.php/Cat/0/Number/10626/page//vc/1
Tienes alguno ejemplo p/ ativar los fuses por código p/ esso PIC18F258 con C18 ? :mrgreen:
Gracias! Saludos!
-
Hola Abdensi
Leyendo la Guía del usuario de C18 encontré esta información...
MPLAB_C18_Users_Guide_51288j.pdf
http://www.4shared.com/dir/251403/ddb5213f/Todopic.html
También busca en microchip: PIC18 Configuration Settings Addendum (DS51537)
2.9.5 #pragma config
The #pragma config directive specifies the processor-specific configuration settings
(i.e., configuration bits) to be used by the application.
Configuration settings may be specified with multiple #pragma config directives.
MPLAB C18 verifies that the configuration settings specified are valid for the processor
for which it is compiling. If a given setting in the configuration byte has not been specified
in any #pragma config directive, the bits associated with that setting will default
to the unprogrammed value.
For each configuration byte for which a setting is specified with the #pragma config
directive, the compiler generates an absolute romdata section named
.config_address_filename, where address is the hexadecimal representation
of the address of the configuration byte, and filename is the name of the object file
being generated. For example, if a configuration setting was specified for the configuration
byte located at address 0x300001 and the source file was compiled with the
command-line option "mcc18 foo.c -fo=foo.o", a romdata section named
.config_300001_foo.o would be created.
2.9.5.1 SYNTAX
pragma-config-directive:
# pragma config setting-list
setting-list:
setting
| setting-list, setting
setting:
setting-name = value-name
The setting-name and value-name are device specific and can be determined by
utilizing the --help-config command-line option. Additionally, the available settings
and associated values for each device are listed in the PIC18 Configuration Settings
Addendum (DS51537).
2.9.5.2 EXAMPLE
The following example shows how the #pragma config directive might be utilized.
The example does the following:
• Enables the Watchdog Timer,
• Sets the Watchdog Postscaler to 1:128, and
• Selects the HS oscillator
#pragma config WDT = ON, WDTPS = 128
#pragma config OSC = HS
...
void main (void)
{
...
}
-
:mrgreen: Me alegro, my test funciona con essas opciones :D
#pragma config OSC = XT
#pragma config OSCS = OFF
#pragma config PWRT = ON
#pragma config BOR = OFF
#pragma config BORV = 20
#pragma config WDT = OFF
#pragma config WDTPS = 1
#pragma config STVR = OFF
#pragma config LVP = OFF
#pragma config DEBUG = OFF
#pragma config CP0 = OFF
#pragma config CP1 = OFF
#pragma config CP2 = OFF
#pragma config CP3 = OFF
#pragma config CPB = OFF
#pragma config CPD = OFF
#pragma config WRT0 = OFF
#pragma config WRT1 = OFF
#pragma config WRT2 = OFF
#pragma config WRT3 = OFF
#pragma config WRTB = OFF
#pragma config WRTC = OFF
#pragma config WRTD = OFF
#pragma config EBTR0 = OFF
#pragma config EBTR1 = OFF
#pragma config EBTR2 = OFF
#pragma config EBTR3 = OFF
#pragma config EBTRB = OFF
Mui gracias Maumix y MigSantiago per la indicaciones :D
El PIC só funciona con XT y 4MHz (per enquanto :D ) Saludos!
-
Es muy curioso, sy reinicio el PIC, no funciona.
Tieno que ligar y desligar el cristal para funcionar.
Estoy muy chateado con esso PIC. No recomiendo PIC 18F258, és mui instable.