Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About sorg

  • Rank
  1. I have tried with 2400 and 4800 Bauds and it was not working! Let's search together the solution!
  2. Which PIC do you use ??? On a 12F675, the following test : while ((ADCon0 & 4) == 4) { nop(); } should be: while ((ADCon0 & [B]2[/B]) == [B]2[/B]) { nop(); } But i don't know if the Adcon0 register have the same shape on each model...
  3. Hello, I'am trying some programming with a 12F675 ... I have the following test code: #include <system.h> #include "main.h" //Config de la liason série #pragma RS232_RXPORT GPIO #pragma RS232_TXPORT GPIO #pragma RS232_RXPIN 4 #pragma RS232_TXPIN 5 #pragma RS232_BAUD 4800 #pragma TRUE_RS232 1 #pragma CLOCK_FREQ 4000000 #define CR 0x0d //Retour Chariot //Message de Bienvenue. const char* bienvenue = " Convertisseur: \0"; //Define device config block asm { list p=PIC12F675 __config H'31C4' } ////////////////////////////////////////////// // Interrupt handler ////////////////////////////////////////////// void interrupt( void ) { } ////////////////////////////////////////////// // Main program entry ////////////////////////////////////////////// main() { //Il faut charger la calibration de l'horloge interne: asm { bsf STATUS, RP0 call 3FFh movwf OSCCAL } //Init interrupt registers //!!! Sample interrupt initialization, correct for your application needs option_reg = 7; // set prescaler to 1:256 //Init ports cmcon = 00000111b; //Comparateur désactivé. set_bit(trisio, 0); //GP0 input ->Mesure set_bit(trisio, 1); //GP1 input ->Vref clear_bit(trisio, 2); //GP2 output ->LED set_bit(trisio, 4); //GP4 input ->RS232-RX clear_bit(trisio, 5); //GP5 output ->RS232-TX gpio = 0; //Init à 0 //Config du CAN clear_bit(adcon0, ADFM); //On veut les 8 MSB set_bit(adcon0, VCFG); //On utilise VREF clear_bit(adcon0, CHS0); // C le channel 0 qui nous intéresse. clear_bit(adcon0, CHS0); set_bit(adcon0, ADON); //On active le convertisseur clear_bit(ansel, ADCS2); // On numérise à la cadence de l'oscillateur interne set_bit(ansel, ADCS1); set_bit(ansel, ADCS0); clear_bit(ansel, ANS3); //AN3 désactivé clear_bit(ansel, ANS2); //AN2 désactivé set_bit(ansel, ANS1); //AN1 activé set_bit(ansel, ANS0); //AN1 activé delay_s(3); //On affiche le message de Bienvenue. char i=0; while(bienvenue[i]) { putchar(bienvenue[i++]); delay_ms(10); } set_bit(adcon0, GO); //on lance la capture while(1) { while( (adcon0 & 2) != 0 ) { } putchar(adresh); set_bit(gpio, 2); delay_ms(500); clear_bit(gpio, 2); delay_ms(500); delay_ms(10); set_bit(adcon0, GO); //on lance la capture } } I have met some problem: For example, I need to put a delay after each putchar command, in order to avoid garbage display on the terminal... is it normal ???? in the main loop ... while (1).... The putchar command don't have any effect... Can you give a clue of the reason.... Thank you for reading me... and for your help!!
  • Create New...