Avr Webserver Eth M32 Ex

Software Description

Website send commands to AVR-Webserver
The commands form the browser are sent via the "OUT" command defined in the javascript function in index.htm.

Example:

<a href="javascript:send('A')"><img src="%PORTA0" border="0"></a> Port A0 - Konturregner<br>

calls the javascript:send() function. This function sends a form-field "OUT" with the character 'A' and a form-field "SUB" with character "x". The "OUT" character is evaluated in "httpd.c" in "httpd_header_check()" in line 300 and triggers a PORT toggle. "SUB" indicates the end of this command.
'A' for example sets a Port, 'K' for example triggers the camera to take a picture.

Website creation in AVR-Webserver
In "httpd.c" in "httpd_data_send()" in line 663, the file "index.htm" is read line-by-line and the variables starting with "%" are replaced by values in function "translate()" in "translate.c".
E.g.

<a href="javascript:send('A')"><img src="%PORTA0" border="0"></a> Port A0 - Konturregner<br>

'%PORTA0' will be replaced by either "led_on.png" or "led_off.png" depending on the status of PORTA0 (on/off).

The same holds true for input pins at line 229.

Problems during bringup - especially with MCA-30 CAM:

Problem: The reset functionality was not reliable when using a 5V/3.6V levelshifter with a resistive divider and a 4069 inverter. When the "CAM_RX" was high during the reset, the "CAM_TX" was high as well and the reset did not work.
Solution: The MCA-30 reset function is ONLY working reliably when the "CAM_EN" and the "CAM_RX" have a pulldown resistor of some kOhm. Dropping the 4069 and using a 1k9+5k1 resistive voltage divider did the job ! A increased delay in mca30_reset_cam() from _delay_ms(100) to _delay_ms(1000).

Problem: After switching to 460800Baud the UART1 buffer had not been empty, so the next command from CAM was not received correctly
Solution: Wait until ATM644P UART1 TX register and UART1 RX register is empty

while (!(CAM_USR & (1<<CAM_UDRE))){} //TX register not empty
while (!(CAM_USR & (1<<CAM_RXC))){} //RX register not empty
char dummy = UDR1; // this reads out the RX register value - required to continue

Problem 1: Using a old and slow SD/MMC card takes too long (268 seconds) to save a picture with lowest resolution 160*120 pixel !
Solution: With a new and fast SD-Card the readout time is reduced to 67 seconds ! For some reason the saving of the picture was much faster after some debugging in the latest version, probably due to enabling interrupts during saving to SD-card. See Problem 3.

Problem 2: The timer counter does not count seconds as realtime seconds - its counting much faster
Solution: After enabling all TCP and 1-wire etc. it works

Problem 3: The color of the saved picture is totally red-shifted - something is wrong with the color. The funlayer are also redshifted - this means biterrors and not CMOS sensor issues !
Could be some DC-supply decoupling issue on CAM or SD-card ?
Solution: Problem was the timing when readout the bits from CAM. Commenting out the "UART disable/enable" commands in mca30.c helped.

Problem 4: After receiving and saving the picture the program does not return to main.c, or at least does not send the UART0 printf_P and printf outputs
Solution: Problem was a 'cli()' (disabling all interrupts) in 'mca30_SaveCamToSD()'. A '//cli()' did solve the problem.

Problem 5: Connection via Telnet does not accept commands —> CR/LF problem ?
Solution:

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License